Skip to content

Commit

Permalink
Fix auth blueprint registration and other stuff
Browse files Browse the repository at this point in the history
I actually tested this in my local dev environment and it worked. I
should have done that a while ago.
  • Loading branch information
mutantmonkey committed Apr 25, 2024
1 parent 4e7ccef commit f593e45
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions wuvt/auth/auth_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ def init_app(self, app):

google_bp = create_flask_blueprint([Google], self.oauth,
handle_authorize)
app.register_blueprint(google_bp, url_prefix='/auth/google')
app.register_blueprint(google_bp, url_prefix='/auth')

self.login_view = 'loginpass_google.login'
self.login_view = 'loginpass.login'
self.login_view_kwargs = {'name': "google"}
elif app.config.get('AUTH_METHOD') == 'oidc':
from authlib.integrations.flask_client import OAuth
self.oauth = OAuth(app)
Expand All @@ -56,9 +57,10 @@ def init_app(self, app):
app.config.get('OIDC_SCOPES'))
oidc_bp = create_flask_blueprint([backend], self.oauth,
handle_authorize)
app.register_blueprint(oidc_bp, url_prefix='/auth/oidc')
app.register_blueprint(oidc_bp, url_prefix='/auth')

self.login_view = 'loginpass_oidc.login'
self.login_view = 'loginpass.login'
self.login_view_kwargs = {'name': "oidc"}
else:
from . import local_views
app.register_blueprint(local_views.bp, url_prefix='/auth/local')
Expand Down Expand Up @@ -94,7 +96,7 @@ def load_user(self, user_id):

def unauthorized(self):
session['login_target'] = request.url
return redirect(url_for(self.login_view))
return redirect(url_for(self.login_view, **self.login_view_kwargs))

def check_access(self, *roles):
roles = set(roles)
Expand Down

0 comments on commit f593e45

Please sign in to comment.