@@ -25,7 +25,7 @@ class KeycloakOAuth2:
25
25
def __init__ (
26
26
self ,
27
27
client_id : str ,
28
- client_secret : str | bytes ,
28
+ client_secret : str | bytes | None ,
29
29
server_metadata_url : str ,
30
30
client_kwargs : dict [str , Any ],
31
31
base_url : str = "/" ,
@@ -39,24 +39,25 @@ def __init__(
39
39
40
40
# TODO pass properly
41
41
# Generated via `openssl genrsa - out keypair.pem 2048`
42
- client_secret = Path ("keypair.pem" ).read_bytes ()
42
+ if not client_secret :
43
+ client_secret = Path ("keypair.pem" ).read_bytes ()
43
44
44
- # Generated via `openssl rsa -in keypair.pem -pubout -out publickey.crt`
45
- self .pub = JsonWebKey .import_key (
46
- Path ("publickey.crt" ).read_text (), {"kty" : "RSA" , "use" : "sig" }
47
- ).as_dict ()
45
+ # Generated via `openssl rsa -in keypair.pem -pubout -out publickey.crt`
46
+ self .pub = JsonWebKey .import_key (
47
+ Path ("publickey.crt" ).read_text (), {"kty" : "RSA" , "use" : "sig" }
48
+ ).as_dict ()
48
49
49
- # TODO call self.keycloak.load_server_metadata() and get token_endpoint
50
- token_endpoint = (
51
- "http://localhost:8180/realms/daewy/protocol/openid-connect/token"
52
- )
53
- auth_method = PrivateKeyJWT (token_endpoint )
54
- client_kwargs .update (
55
- {
56
- "client_auth_methods" : [auth_method ],
57
- "token_endpoint_auth_method" : auth_method .name ,
58
- }
59
- )
50
+ # TODO call self.keycloak.load_server_metadata() and get token_endpoint
51
+ token_endpoint = (
52
+ "http://localhost:8180/realms/daewy/protocol/openid-connect/token"
53
+ )
54
+ auth_method = PrivateKeyJWT (token_endpoint )
55
+ client_kwargs .update (
56
+ {
57
+ "client_auth_methods" : [auth_method ],
58
+ "token_endpoint_auth_method" : auth_method .name ,
59
+ }
60
+ )
60
61
61
62
oauth .register (
62
63
name = "keycloak" ,
0 commit comments