MCPcopy Create free account
hub / github.com/authlib/authlib / AuthorizationServerMetadata

Class AuthorizationServerMetadata

authlib/oauth2/rfc8414/models.py:7–388  ·  view source on GitHub ↗

Define Authorization Server Metadata per :rfc:`8414#section-2`. The :meth:`validate` method can compose extension classes via the ``metadata_classes`` parameter:: from authlib.oauth2 import rfc8414, rfc9101 metadata = rfc8414.AuthorizationServerMetadata(data) metad

Source from the content-addressed store, hash-verified

5
6
7class AuthorizationServerMetadata(dict):
8 """Define Authorization Server Metadata per :rfc:`8414#section-2`.
9
10 The :meth:`validate` method can compose extension classes via the
11 ``metadata_classes`` parameter::
12
13 from authlib.oauth2 import rfc8414, rfc9101
14
15 metadata = rfc8414.AuthorizationServerMetadata(data)
16 metadata.validate(metadata_classes=[rfc9101.AuthorizationServerMetadata])
17 """
18
19 REGISTRY_KEYS = [
20 "issuer",
21 "authorization_endpoint",
22 "token_endpoint",
23 "jwks_uri",
24 "registration_endpoint",
25 "scopes_supported",
26 "response_types_supported",
27 "response_modes_supported",
28 "grant_types_supported",
29 "token_endpoint_auth_methods_supported",
30 "token_endpoint_auth_signing_alg_values_supported",
31 "service_documentation",
32 "ui_locales_supported",
33 "op_policy_uri",
34 "op_tos_uri",
35 "revocation_endpoint",
36 "revocation_endpoint_auth_methods_supported",
37 "revocation_endpoint_auth_signing_alg_values_supported",
38 "introspection_endpoint",
39 "introspection_endpoint_auth_methods_supported",
40 "introspection_endpoint_auth_signing_alg_values_supported",
41 "code_challenge_methods_supported",
42 ]
43
44 def validate_issuer(self):
45 """REQUIRED. The authorization server's issuer identifier, which is
46 a URL that uses the "https" scheme and has no query or fragment
47 components.
48 """
49 issuer = self.get("issuer")
50
51 #: 1. REQUIRED
52 if not issuer:
53 raise ValueError('"issuer" is required')
54
55 parsed = urlparse.urlparse(issuer)
56
57 #: 2. uses the "https" scheme
58 if not is_secure_transport(issuer):
59 raise ValueError('"issuer" MUST use "https" scheme')
60
61 #: 3. has no query or fragment
62 if parsed.query or parsed.fragment:
63 raise ValueError('"issuer" has no query or fragment')
64

Calls

no outgoing calls