Skip to content

Commit

Permalink
Refactor file reading
Browse files Browse the repository at this point in the history
  • Loading branch information
disrupted authored and torbsto committed Mar 4, 2024
1 parent b1798fe commit 029d6fb
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions keycloak/oauth.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pathlib import Path
from typing import Any
import pydantic
from authlib.common.security import generate_token
Expand Down Expand Up @@ -38,14 +39,12 @@ def __init__(

# TODO pass properly
# Generated via `openssl genrsa - out keypair.pem 2048`
with open("keypair.pem", "rb") as f:
client_secret = f.read()
client_secret = Path("keypair.pem").read_bytes()

# Generated via `openssl rsa -in keypair.pem -pubout -out publickey.crt`
with open("publickey.crt", "r") as f:
self.pub = JsonWebKey.import_key(
f.read(), {"kty": "RSA", "use": "sig"}
).as_dict()
self.pub = JsonWebKey.import_key(
Path("publickey.crt").read_text(), {"kty": "RSA", "use": "sig"}
).as_dict()

# TODO call self.keycloak.load_server_metadata() and get token_endpoint
token_endpoint = (
Expand Down

0 comments on commit 029d6fb

Please sign in to comment.