Skip to content

Commit

Permalink
Add TokenVerifier.force
Browse files Browse the repository at this point in the history
  • Loading branch information
caspervdw committed Aug 16, 2023
1 parent 3d4aa45 commit e9c611f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
0.3.1 (unreleased)
------------------

- Nothing changed yet.
- Added `TokenVerifier.force()` for testing purposes.


0.3.0 (2023-08-16)
Expand Down
13 changes: 12 additions & 1 deletion clean_python/oauth2/token_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,24 @@ class OAuth2SPAClientSettings(BaseModel):


class BaseTokenVerifier:
def force(self, token: Token) -> None:
raise NotImplementedError()

def __call__(self, authorization: Optional[str]) -> Token:
raise NotImplementedError()


class NoAuthTokenVerifier(BaseTokenVerifier):
def __init__(self):
self.token = Token(
claims={"sub": "DEV", "username": "dev", "scope": "superuser"}
)

def force(self, token: Token) -> None:
self.token = token

def __call__(self, authorization: Optional[str]) -> Token:
return Token(claims={"sub": "DEV", "username": "dev", "scope": "superuser"})
return self.token


class TokenVerifier(BaseTokenVerifier):
Expand Down

0 comments on commit e9c611f

Please sign in to comment.