MCPcopy
hub / github.com/authlib/authlib / encode_id_token

Method encode_id_token

authlib/oidc/core/grants/code.py:60–85  ·  view source on GitHub ↗
(self, token, request: OAuth2Request)

Source from the content-addressed store, hash-verified

58 raise NotImplementedError()
59
60 def encode_id_token(self, token, request: OAuth2Request):
61 alg = self.get_client_algorithm(request.client)
62 header = self.get_encode_header(request.client)
63
64 claims = self.get_compatible_claims(request)
65 if request.authorization_code:
66 claims.update(
67 self.get_authorization_code_claims(request.authorization_code)
68 )
69
70 access_token = token.get("access_token")
71 if access_token:
72 at_hash = create_half_hash(access_token, alg)
73 if at_hash is not None:
74 claims["at_hash"] = at_hash.decode("utf-8")
75
76 user_info = self.generate_user_info(request.user, token["scope"])
77 claims.update(user_info)
78
79 if alg == "none":
80 private_key = None
81 else:
82 key = self.resolve_client_private_key(request.client)
83 private_key = import_any_key(key)
84
85 return jwt.encode(header, claims, private_key, [alg])
86
87 def process_token(self, grant, response):
88 _, token, _ = response

Callers 1

process_tokenMethod · 0.95

Calls 11

generate_user_infoMethod · 0.95
import_any_keyFunction · 0.90
create_half_hashFunction · 0.85
get_client_algorithmMethod · 0.80
get_encode_headerMethod · 0.80
get_compatible_claimsMethod · 0.80
decodeMethod · 0.80
encodeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected