Implement RFC 7523 JWT flows (#1247)

Co-authored-by: Yann Jouanin <yann.jouanin@valueandco.com>
This commit is contained in:
Luca Chang 2025-10-29 09:48:08 -07:00 • committed by GitHub
commit f161149680
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -39,11 +39,13 @@ class MockOAuthProvider(OAuthAuthorizationServerProvider[AuthorizationCode, Refr
return self.clients.get(client_id)
async def register_client(self, client_info: OAuthClientInformationFull):
assert client_info.client_id is not None
self.clients[client_info.client_id] = client_info
async def authorize(self, client: OAuthClientInformationFull, params: AuthorizationParams) -> str:
# toy authorize implementation which just immediately generates an authorization
# code and completes the redirect
assert client.client_id is not None
code = AuthorizationCode(
code=f"code_{int(time.time())}",
client_id=client.client_id,
@ -72,6 +74,7 @@ class MockOAuthProvider(OAuthAuthorizationServerProvider[AuthorizationCode, Refr
refresh_token = f"refresh_{secrets.token_hex(32)}"
# Store the tokens
assert client.client_id is not None
self.tokens[access_token] = AccessToken(
token=access_token,
client_id=client.client_id,
@ -133,6 +136,7 @@ class MockOAuthProvider(OAuthAuthorizationServerProvider[AuthorizationCode, Refr
new_refresh_token = f"refresh_{secrets.token_hex(32)}"
# Store the new tokens
assert client.client_id is not None
self.tokens[new_access_token] = AccessToken(
token=new_access_token,
client_id=client.client_id,