Skip to content

Commit

Permalink
Site: Handle Authorization Bearer Tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorNelson committed Oct 7, 2024
1 parent 5b4ee1d commit 0dc67d2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dojo_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ def redirect_dojo():
return redirect(redirect_url, code=301)


def handle_authorization(default_handler):
authorization = request.headers.get("Authorization")
if authorization and authorization.startswith("Bearer "):
return
default_handler()


def load(app):
db.create_all()

Expand Down Expand Up @@ -145,6 +152,10 @@ def load(app):
register_admin_plugin_menu_bar("Dojos", "/admin/dojos")
register_admin_plugin_menu_bar("Desktops", "/admin/desktops")

before_request_funcs = app.before_request_funcs[None]
tokens_handler = next(func for func in before_request_funcs if func.__name__ == "tokens")
before_request_funcs[before_request_funcs.index(tokens_handler)] = lambda: handle_authorization(tokens_handler)

if os.path.basename(sys.argv[0]) != "manage.py":
bootstrap()

Expand Down

0 comments on commit 0dc67d2

Please sign in to comment.