|
72 | 72 | (b"oidc_session_no_samesite", b"HttpOnly"), |
73 | 73 | ] |
74 | 74 |
|
| 75 | + |
75 | 76 | #: A token exchanged from the token endpoint, as per RFC6749 sec 5.1. and |
76 | 77 | #: OpenID.Core sec 3.1.3.3. |
77 | | -Token = TypedDict( |
78 | | - "Token", |
79 | | - { |
80 | | - "access_token": str, |
81 | | - "token_type": str, |
82 | | - "id_token": Optional[str], |
83 | | - "refresh_token": Optional[str], |
84 | | - "expires_in": int, |
85 | | - "scope": Optional[str], |
86 | | - }, |
87 | | -) |
| 78 | +class Token(TypedDict): |
| 79 | + access_token: str |
| 80 | + token_type: str |
| 81 | + id_token: Optional[str] |
| 82 | + refresh_token: Optional[str] |
| 83 | + expires_in: int |
| 84 | + scope: Optional[str] |
| 85 | + |
88 | 86 |
|
89 | 87 | #: A JWK, as per RFC7517 sec 4. The type could be more precise than that, but |
90 | 88 | #: there is no real point of doing this in our case. |
91 | 89 | JWK = Dict[str, str] |
92 | 90 |
|
| 91 | + |
93 | 92 | #: A JWK Set, as per RFC7517 sec 5. |
94 | | -JWKS = TypedDict("JWKS", {"keys": List[JWK]}) |
| 93 | +class JWKS(TypedDict): |
| 94 | + keys: List[JWK] |
95 | 95 |
|
96 | 96 |
|
97 | 97 | class OidcHandler: |
@@ -255,7 +255,7 @@ def __init__(self, error, error_description=None): |
255 | 255 |
|
256 | 256 | def __str__(self): |
257 | 257 | if self.error_description: |
258 | | - return "{}: {}".format(self.error, self.error_description) |
| 258 | + return f"{self.error}: {self.error_description}" |
259 | 259 | return self.error |
260 | 260 |
|
261 | 261 |
|
@@ -639,7 +639,7 @@ async def _exchange_code(self, code: str) -> Token: |
639 | 639 | ) |
640 | 640 | logger.warning(description) |
641 | 641 | # Body was still valid JSON. Might be useful to log it for debugging. |
642 | | - logger.warning("Code exchange response: {resp!r}".format(resp=resp)) |
| 642 | + logger.warning("Code exchange response: %r", resp) |
643 | 643 | raise OidcError("server_error", description) |
644 | 644 |
|
645 | 645 | return resp |
@@ -1217,10 +1217,12 @@ class OidcSessionData: |
1217 | 1217 | ui_auth_session_id = attr.ib(type=str) |
1218 | 1218 |
|
1219 | 1219 |
|
1220 | | -UserAttributeDict = TypedDict( |
1221 | | - "UserAttributeDict", |
1222 | | - {"localpart": Optional[str], "display_name": Optional[str], "emails": List[str]}, |
1223 | | -) |
| 1220 | +class UserAttributeDict(TypedDict): |
| 1221 | + localpart: Optional[str] |
| 1222 | + display_name: Optional[str] |
| 1223 | + emails: List[str] |
| 1224 | + |
| 1225 | + |
1224 | 1226 | C = TypeVar("C") |
1225 | 1227 |
|
1226 | 1228 |
|
|
0 commit comments