-
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 Authenticators to make use of inheritance
- Loading branch information
1 parent
1f5779d
commit a04d11a
Showing
6 changed files
with
52 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
from dataclasses import dataclass | ||
from typing import Protocol | ||
|
||
from abc import ABC | ||
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) -> UserSessionState | None: | ||
raise NotImplemented | ||
|
||
|
||
class Authenticator(Protocol): | ||
def authenticate(self, request: Request) -> UserSessionState: | ||
pass | ||
class ExternalAuthenticator(ABC): | ||
def authenticate(self, request: Request) -> UserSessionState | None: | ||
raise NotImplemented |
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