Skip to content

Commit

Permalink
Merge pull request #540 from yanomaly/fix/custom-unauth-actions
Browse files Browse the repository at this point in the history
fix: add opportunity to customize unauthorization and callback actions
  • Loading branch information
ramedina86 authored Aug 27, 2024
2 parents d60812c + 0b89a08 commit 9d3783d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/writer/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def register(self,
callback: Optional[Callable[[Request, str, dict], None]] = None,
unauthorized_action: Optional[Callable[[Request, Unauthorized], Response]] = None):

self.unauthorized_action = unauthorized_action
self.callback_func = callback

@asgi_app.middleware("http")
async def basicauth_middleware(request: Request, call_next):
import base64
Expand Down Expand Up @@ -205,6 +208,7 @@ def register(self,
token_endpoint=self.url_oauthtoken,
)

self.unauthorized_action = unauthorized_action
self.callback_func = callback

@asgi_app.middleware("http")
Expand Down

0 comments on commit 9d3783d

Please sign in to comment.