forked from rohe/oidc-swamid-federation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_fo_bundle.py
executable file
·35 lines (26 loc) · 1.04 KB
/
create_fo_bundle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
import os
from urllib.parse import quote_plus
from urllib.parse import unquote_plus
from fedoidcmsg.bundle import FSJWKSBundle
from fedoidcmsg.test_utils import create_federation_entities
from cryptojwt.key_jar import KeyJar
# make sure the necessary directories are there
for _dir in ['public', 'private', 'fo_bundle']:
if not os.path.isdir(_dir):
os.mkdir(_dir)
# The kind of keys the federation entities has
FED_KEYDEF = [{"type": "EC", "crv": "P-256", "use": ["sig"]}]
# Identifiers for all the Federations
ALL = ['https://edugain.org', 'https://swamid.sunet.se']
_path = os.path.realpath(__file__)
root_dir, _fname = os.path.split(_path)
# Create the federation entities
FEDENT = create_federation_entities(ALL, FED_KEYDEF, root_dir=root_dir)
# create and load the key bundle
bundle = FSJWKSBundle(iss='jra3t3', fdir='fo_bundle',
key_conv={'to': quote_plus, 'from': unquote_plus})
for iss in ALL:
kj = KeyJar()
kj.import_jwks(FEDENT[iss].signing_keys_as_jwks(), iss)
bundle[iss] = kj