Skip to content

Commit

Permalink
feat: support optionally passing login query string to oauth authoriz…
Browse files Browse the repository at this point in the history
…e redirect
  • Loading branch information
scarbeau committed Mar 21, 2024
1 parent c65e067 commit ebd0aa0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions flask_appbuilder/security/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,11 @@ def login(self, provider: Optional[str] = None) -> WerkzeugResponse:
request.args.to_dict(flat=False), random_state, algorithm="HS256"
)
session["oauth_state"] = random_state

params = {}
if current_app.config.get("AUTH_OAUTH_PRESERVE_LOGIN_QUERY", False):
params = request.args

Check warning on line 649 in flask_appbuilder/security/views.py

View check run for this annotation

Codecov / codecov/patch

flask_appbuilder/security/views.py#L647-L649

Added lines #L647 - L649 were not covered by tests

try:
if provider == "twitter":
return self.appbuilder.sm.oauth_remotes[provider].authorize_redirect(
Expand All @@ -659,6 +664,7 @@ def login(self, provider: Optional[str] = None) -> WerkzeugResponse:
".oauth_authorized", provider=provider, _external=True
),
state=state.decode("ascii") if isinstance(state, bytes) else state,
**params,
)
except Exception as e:
log.error("Error on OAuth authorize: %s", e)
Expand Down

0 comments on commit ebd0aa0

Please sign in to comment.