add integration

This commit is contained in:
2025-08-06 18:46:21 -03:00
parent e08f16bbaa
commit ff25ade76e
16 changed files with 314 additions and 132 deletions

View File

@@ -7,13 +7,13 @@ from aws_lambda_powertools.event_handler.exceptions import NotFoundError
from layercake.dateutils import now, ttl
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair
from apigateway_oauth2 import (
from boto3clients import dynamodb_client
from config import DYNAMODB_SORT_KEY, OAUTH2_TABLE
from integrations.apigateway_oauth2 import (
AuthorizationServer,
OAuth2Client,
OAuth2Token,
)
from boto3clients import dynamodb_client
from config import DYNAMODB_SORT_KEY, OAUTH2_TABLE
oauth2_layer = DynamoDBPersistenceLayer(OAUTH2_TABLE, dynamodb_client)
@@ -33,12 +33,11 @@ def create_save_token_func(persistence_layer: DynamoDBPersistenceLayer):
return save_token
class ClientNotFoundError(NotFoundError):
def __init__(self, *_):
super().__init__('Client not found')
def create_query_client_func(persistence_layer: DynamoDBPersistenceLayer):
class ClientNotFoundError(NotFoundError):
def __init__(self, *_):
super().__init__('Client not found')
def query_client(client_id) -> OAuth2Client:
client = persistence_layer.collection.get_item(
KeyPair('OAUTH2_CLIENT', f'CLIENT_ID#{client_id}'),
@@ -89,19 +88,16 @@ def save_authorization_code(code, request):
)
def exists_nonce(nonce, request):
nonce_ = oauth2_layer.get_item(
KeyPair(
f'OAUTH2_CODE#CLIENT_ID#{request.payload.client_id}',
f'NONCE#{nonce}',
)
)
return bool(nonce_)
class OpenIDCode(OpenIDCode_):
def exists_nonce(self, nonce, request):
return exists_nonce(nonce, request)
nonce_ = oauth2_layer.get_item(
KeyPair(
f'OAUTH2_CODE#CLIENT_ID#{request.payload.client_id}', # type:ignore
f'NONCE#{nonce}',
)
)
return bool(nonce_)
def get_jwt_config(self, grant):
return DUMMY_JWT_CONFIG