-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor authentication providers to use inheritance (#856)
- Loading branch information
1 parent
5a48730
commit 444515c
Showing
11 changed files
with
72 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
from abc import ABC | ||
from dataclasses import dataclass | ||
from typing import Protocol | ||
from typing import Optional | ||
|
||
from fastapi import Request | ||
|
||
|
||
@dataclass | ||
class UserSessionState: | ||
"""Data transfer class to communicate custom session state infromation.""" | ||
"""Data transfer class to communicate custom session state information.""" | ||
|
||
user_name: str | ||
state: dict = None | ||
|
||
|
||
class UsernamePasswordAuthenticator(Protocol): | ||
def authenticate(self, username: str, password: str) -> UserSessionState: | ||
pass | ||
class InternalAuthenticator(ABC): | ||
def authenticate(self, username: str, password: str) -> Optional[UserSessionState]: | ||
raise NotImplementedError | ||
|
||
|
||
class Authenticator(Protocol): | ||
def authenticate(self, request: Request) -> UserSessionState: | ||
pass | ||
class ExternalAuthenticator(ABC): | ||
def authenticate(self, request: Request) -> Optional[UserSessionState]: | ||
raise NotImplementedError |
Oops, something went wrong.