23
23
from starlette .types import Send
24
24
25
25
from .claims import Claims
26
- from .client import OAuth2Client
27
26
from .config import OAuth2Config
28
27
from .core import OAuth2Core
29
28
@@ -37,32 +36,8 @@ class Auth(AuthCredentials):
37
36
expires : int
38
37
algorithm : str
39
38
scopes : List [str ]
40
- provider : OAuth2Core = None
41
- clients : Dict [str , OAuth2Core ] = {}
42
-
43
- @classmethod
44
- def set_ssr (cls , ssr : bool ) -> None :
45
- cls .ssr = ssr
46
-
47
- @classmethod
48
- def set_http (cls , http : bool ) -> None :
49
- cls .http = http
50
-
51
- @classmethod
52
- def set_secret (cls , secret : str ) -> None :
53
- cls .secret = secret
54
-
55
- @classmethod
56
- def set_expires (cls , expires : int ) -> None :
57
- cls .expires = expires
58
-
59
- @classmethod
60
- def set_algorithm (cls , algorithm : str ) -> None :
61
- cls .algorithm = algorithm
62
-
63
- @classmethod
64
- def register_client (cls , client : OAuth2Client ) -> None :
65
- cls .clients [client .backend .name ] = OAuth2Core (client )
39
+ provider : OAuth2Core
40
+ clients : Dict [str , OAuth2Core ]
66
41
67
42
@classmethod
68
43
def jwt_encode (cls , data : dict ) -> str :
@@ -122,13 +97,15 @@ def __init__(
122
97
config : OAuth2Config ,
123
98
callback : Callable [[Auth , User ], Union [Awaitable [None ], None ]] = None ,
124
99
) -> None :
125
- Auth .set_ssr (config .enable_ssr )
126
- Auth .set_http (config .allow_http )
127
- Auth .set_secret (config .jwt_secret )
128
- Auth .set_expires (config .jwt_expires )
129
- Auth .set_algorithm (config .jwt_algorithm )
130
- for client in config .clients :
131
- Auth .register_client (client )
100
+ Auth .ssr = config .enable_ssr
101
+ Auth .http = config .allow_http
102
+ Auth .secret = config .jwt_secret
103
+ Auth .expires = config .jwt_expires
104
+ Auth .algorithm = config .jwt_algorithm
105
+ Auth .clients = {
106
+ client .backend .name : OAuth2Core (client )
107
+ for client in config .clients
108
+ }
132
109
self .callback = callback
133
110
134
111
async def authenticate (self , request : Request ) -> Optional [Tuple [Auth , User ]]:
0 commit comments