* Added a failing test for the multi-oauth-router issue

* Fixed the #823 regression.

Using a regex for the backend name validation instead of an enum.

* Fixed formatting errors

* Moved the `AuthenticationBackendName` enum to `Authenticator`

This prevents an issue with OpenAPI schema generation caused by two
endpoints accepting a parameter with a duplicate name.
This commit is contained in:
Matyáš Richter
2021-12-29 13:25:15 +01:00
committed by GitHub
parent e0ae193848
commit 2e8f1f2eb2
3 changed files with 26 additions and 7 deletions

View File

@@ -1,3 +1,4 @@
import enum
import re
from inspect import Parameter, Signature
from typing import Callable, Optional, Sequence
@@ -42,6 +43,7 @@ class Authenticator:
"""
backends: Sequence[BaseAuthentication]
backends_enum: enum.Enum
def __init__(
self,
@@ -49,6 +51,10 @@ class Authenticator:
get_user_manager: UserManagerDependency[models.UC, models.UD],
):
self.backends = backends
self.backends_enum = enum.Enum( # type: ignore
"AuthenticationBackendName",
{backend.name: backend.name for backend in backends}, # type: ignore
)
self.get_user_manager = get_user_manager
def current_user(