Skip to content

Commit

Permalink
fix: Check if Oauth login with OKTA is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
safeith committed Mar 11, 2024
1 parent 0ab8b4e commit adea7d8
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions flask_appbuilder/security/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,13 +660,17 @@ def get_oauth_user_info(
me = self.appbuilder.sm.oauth_remotes[provider].get("userinfo")
data = me.json()
log.debug("User info from Okta: %s", data)
return {
"username": f"{provider}_{data['sub']}",
"first_name": data.get("given_name", ""),
"last_name": data.get("family_name", ""),
"email": data["email"],
"role_keys": data.get("groups", []),
}
if "error" not in data:
return {

Check warning on line 664 in flask_appbuilder/security/manager.py

View check run for this annotation

Codecov / codecov/patch

flask_appbuilder/security/manager.py#L663-L664

Added lines #L663 - L664 were not covered by tests
"username": f"{provider}_{data['sub']}",
"first_name": data.get("given_name", ""),
"last_name": data.get("family_name", ""),
"email": data["email"],
"role_keys": data.get("groups", []),
}
else:
log.error(data.get("error_description"))
return {}

Check warning on line 673 in flask_appbuilder/security/manager.py

View check run for this annotation

Codecov / codecov/patch

flask_appbuilder/security/manager.py#L672-L673

Added lines #L672 - L673 were not covered by tests
# for Auth0
if provider == "auth0":
data = self.appbuilder.sm.oauth_remotes[provider].userinfo()
Expand Down

0 comments on commit adea7d8

Please sign in to comment.