update session
This commit is contained in:
@@ -3,6 +3,7 @@ from authlib.common.urls import add_params_to_uri
|
||||
from authlib.jose import JsonWebKey
|
||||
from authlib.oauth2 import OAuth2Request, rfc7009, rfc9207
|
||||
from authlib.oauth2.rfc6749 import ClientMixin, TokenMixin, grants
|
||||
from authlib.oauth2.rfc6749.hooks import hooked
|
||||
from authlib.oauth2.rfc6750 import BearerTokenGenerator
|
||||
from authlib.oauth2.rfc7636 import CodeChallenge
|
||||
from authlib.oauth2.rfc9068 import JWTBearerTokenGenerator as JWTBearerTokenGenerator_
|
||||
@@ -21,7 +22,7 @@ from layercake.dynamodb import (
|
||||
from layercake.funcs import omit, pick
|
||||
|
||||
from boto3clients import dynamodb_client
|
||||
from config import ISSUER, OAUTH2_TABLE
|
||||
from config import ISSUER, OAUTH2_SCOPES_SUPPORTED, OAUTH2_TABLE
|
||||
from integrations.apigateway_oauth2.authorization_server import (
|
||||
AuthorizationServer,
|
||||
)
|
||||
@@ -64,6 +65,8 @@ class OpenIDCode(OpenIDCode_):
|
||||
}
|
||||
|
||||
def generate_user_info(self, user: User, scope: str) -> UserInfo:
|
||||
print(scope)
|
||||
print('--' * 100)
|
||||
return UserInfo(
|
||||
sub=user.id,
|
||||
name=user.name,
|
||||
@@ -173,6 +176,20 @@ class AuthorizationCodeGrant(grants.AuthorizationCodeGrant):
|
||||
return User(**pick(('id', 'name', 'email', 'email_verified'), user))
|
||||
|
||||
|
||||
class TokenExchangeGrant(grants.BaseGrant):
|
||||
GRANT_TYPE = 'urn:ietf:params:oauth:grant-type:token-exchange'
|
||||
|
||||
TOKEN_ENDPOINT_AUTH_METHODS = ['client_secret_basic', 'client_secret_post']
|
||||
|
||||
@hooked
|
||||
def validate_token_request(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
@hooked
|
||||
def create_token_response(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class RefreshTokenNotFoundError(NotFoundError):
|
||||
def __init__(self, *_):
|
||||
super().__init__('Refresh token not found')
|
||||
@@ -337,7 +354,10 @@ class JWTBearerTokenGenerator(JWTBearerTokenGenerator_):
|
||||
}
|
||||
|
||||
|
||||
server = AuthorizationServer(persistence_layer=dyn)
|
||||
server = AuthorizationServer(
|
||||
persistence_layer=dyn,
|
||||
scopes_supported=OAUTH2_SCOPES_SUPPORTED,
|
||||
)
|
||||
server.register_grant(
|
||||
AuthorizationCodeGrant,
|
||||
[
|
||||
@@ -353,6 +373,7 @@ server.register_token_generator(
|
||||
expires_generator=expires_in,
|
||||
),
|
||||
)
|
||||
server.register_grant(TokenExchangeGrant)
|
||||
server.register_grant(RefreshTokenGrant)
|
||||
server.register_endpoint(RevocationEndpoint)
|
||||
server.register_extension(IssuerParameter())
|
||||
|
||||
Reference in New Issue
Block a user