from aws_lambda_powertools.event_handler.api_gateway import Router

from config import ISSUER, OAUTH2_SCOPES_SUPPORTED

router = Router()


@router.get('/.well-known/openid-configuration')
def openid_configuration():
    return {
        'issuer': ISSUER,
        'authorization_endpoint': f'{ISSUER}/authorize',
        'token_endpoint': f'{ISSUER}/token',
        'revocation_endpoint': f'{ISSUER}/revoke',
        'userinfo_endpoint': f'{ISSUER}/userinfo',
        'jwks_uri': f'{ISSUER}/.well-known/jwks.json',
        'scopes_supported': OAUTH2_SCOPES_SUPPORTED,
        'response_types_supported': ['code'],
        'grant_types_supported': ['authorization_code', 'refresh_token'],
        'subject_types_supported': ['public'],
        'id_token_signing_alg_values_supported': ['RS256'],
        'token_endpoint_auth_methods_supported': [
            'client_secret_basic',
            'client_secret_post',
            'none',
        ],
    }
