|
15 | 15 | from fastapi.middleware.cors import CORSMiddleware |
16 | 16 | from fastapi.openapi.utils import get_openapi |
17 | 17 |
|
18 | | -from .authentication import Mode |
| 18 | +from .authentication import ExternalAuthenticator, InternalAuthenticator |
19 | 19 | from .console_output import CollectPublishedConsoleOutput, ConsoleOutputStream, SystemInfoStream |
20 | 20 | from .core import PatchedStreamingResponse |
21 | 21 | from .database.core import purge_expired |
@@ -179,20 +179,19 @@ def build_app(authentication=None, api_access=None, resource_access=None, server |
179 | 179 | for spec in authentication["providers"]: |
180 | 180 | provider = spec["provider"] |
181 | 181 | authenticator = spec["authenticator"] |
182 | | - mode = authenticator.mode |
183 | | - if mode == Mode.password: |
| 182 | + if isinstance(authenticator, InternalAuthenticator): |
184 | 183 | authentication_router.post(f"/provider/{provider}/token")( |
185 | 184 | build_handle_credentials_route(authenticator, provider) |
186 | 185 | ) |
187 | | - elif mode == Mode.external: |
| 186 | + elif isinstance(authenticator, ExternalAuthenticator): |
188 | 187 | authentication_router.get(f"/provider/{provider}/code")( |
189 | 188 | build_auth_code_route(authenticator, provider) |
190 | 189 | ) |
191 | 190 | authentication_router.post(f"/provider/{provider}/code")( |
192 | 191 | build_auth_code_route(authenticator, provider) |
193 | 192 | ) |
194 | 193 | else: |
195 | | - raise ValueError(f"unknown authentication mode {mode}") |
| 194 | + raise ValueError(f"unknown authenticator type {type(authenticator)}") |
196 | 195 | for custom_router in getattr(authenticator, "include_routers", []): |
197 | 196 | authentication_router.include_router(custom_router, prefix=f"/provider/{provider}") |
198 | 197 |
|
|
0 commit comments