Beispiel #1
0
 def test_with_external(self):
     self.assertEqual(
         get_well_known_url('https://authlib.org', external=True),
         'https://authlib.org' + WELL_KNOWN_URL)
Beispiel #2
0
 def test_with_suffix_issuer(self):
     self.assertEqual(get_well_known_url('https://authlib.org/issuer1'),
                      '/issuer1' + WELL_KNOWN_URL)
     self.assertEqual(get_well_known_url('https://authlib.org/a/b/c'),
                      '/a/b/c' + WELL_KNOWN_URL)
Beispiel #3
0
 def test_no_suffix_issuer(self):
     self.assertEqual(get_well_known_url('https://authlib.org'),
                      WELL_KNOWN_URL)
     self.assertEqual(get_well_known_url('https://authlib.org/'),
                      WELL_KNOWN_URL)
Beispiel #4
0
from ..fastapi_session.impl import (
    AuthorizationCodeGrant,
    OpenIDCode,
    RefreshTokenGrant,
    JWTBearer,
)
from ..fastapi_session.impl import (
    AuthorizationServer,
    save_token,
)
from ..fastapi_session.models import User, Client, Identity
from ..starlette_oauth2.async_authenticate_client import ClientAuthentication

SCOPES = dict(openid="Any user login requires this scope.",
              admin="Admin permissions.")
OPENID_CONFIGURATION_ENDPOINT = get_well_known_url("")
AUTHORIZATION_ENDPOINT = "/oauth2/authorize"
TOKEN_ENDPOINT = "/oauth2/token"
USERINFO_ENDPOINT = "/userinfo"
JWKS_URI = "/.well-known/jwks.json"

oidc_scheme = JWTBearer(
    AUTHORIZATION_ENDPOINT,
    TOKEN_ENDPOINT,
    scheme_name="oidc",
    scopes=SCOPES,
    auto_error=False,
)
metadata = OpenIDProviderMetadata(
    issuer=config.JWT_ISSUER,
    authorization_endpoint=config.JWT_ISSUER + AUTHORIZATION_ENDPOINT,
Beispiel #5
0
 def oidc_config(self):
     return requests.get(
         get_well_known_url(api_settings.OIDC_ENDPOINT,
                            external=True)).json()