Skip to content

Commit

Permalink
remove uncheckable and unsound properties because not in interface or
Browse files Browse the repository at this point in the history
not correctly defined

first: they are all not defined as interface in docs

is_active: defaults to False, also False for BasicUser
is_anonymous: not defined in BaseUser. Afaik cannot be checked safely.
Rendundant for is_authenticated
get_id: return None
identity: raises NotImplemented and not in docs specified
  • Loading branch information
devkral committed Dec 20, 2024
1 parent 8c4d23b commit 10d9113
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
3 changes: 1 addition & 2 deletions docs/en/docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ The implementation should implement the inteface `UserInterface`, which includes
* `.is_authenticated`
* `.display_name`

Lilya provides two built-in user implementations: `AnonymousUser()`,
and `BasicUser(username)`.
Lilya provides two built-in user implementations: `AnonymousUser()` and `BasicUser(username)`.

## AuthCredentials

Expand Down
10 changes: 2 additions & 8 deletions lilya/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def sync_wrapper(*args: P.args, **kwargs: P.kwargs) -> typing.Any:
class AuthenticationError(Exception): ...


@typing.runtime_checkable
class AuthenticationBackend(ABC, typing.Protocol):
@abstractmethod
async def authenticate(self, connection: Connection) -> AuthResult | None: ...
Expand All @@ -170,11 +171,8 @@ def __init__(self, scopes: typing.Sequence[str] | None = None):
self.scopes = [] if scopes is None else list(scopes)


@typing.runtime_checkable
class UserInterface(typing.Protocol):
@property
def is_active(self) -> bool:
return False

@property
def is_authenticated(self) -> bool:
raise NotImplementedError()
Expand Down Expand Up @@ -209,7 +207,3 @@ def is_authenticated(self) -> bool:
@property
def display_name(self) -> str:
return ""

@property
def is_anonymous(self) -> bool:
return True

0 comments on commit 10d9113

Please sign in to comment.