mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
notify-admin-338 login.gov integration
This commit is contained in:
@@ -17,7 +17,6 @@ from flask import (
|
||||
)
|
||||
from flask_login import current_user
|
||||
|
||||
|
||||
from app import login_manager, user_api_client
|
||||
from app.main import main
|
||||
from app.main.forms import LoginForm
|
||||
@@ -62,7 +61,6 @@ def _get_user_email(access_token):
|
||||
user_info_url,
|
||||
headers=headers,
|
||||
)
|
||||
current_app.logger.info(f"HURRAY GOT USER ATTRIBUTES {user_attributes.json()}")
|
||||
user_email = user_attributes.json()["email"]
|
||||
return user_email
|
||||
|
||||
@@ -85,7 +83,7 @@ def sign_in():
|
||||
return redirect(url_for("main.show_accounts_or_dashboard", next=redirect_url))
|
||||
|
||||
elif login_gov_error:
|
||||
current_app.logger.error(f"BOO! GOT A LOGIN GOV ERROR {login_gov_error}")
|
||||
current_app.logger.error(f"login.gov error: {login_gov_error}")
|
||||
raise Exception(f"Could not login with login.gov {login_gov_error}")
|
||||
# end login.gov
|
||||
|
||||
@@ -149,11 +147,13 @@ def sign_in():
|
||||
)
|
||||
|
||||
other_device = current_user.logged_in_elsewhere()
|
||||
notify_env = os.getenv("NOTIFY_ENVIRONMENT")
|
||||
return render_template(
|
||||
"views/signin.html",
|
||||
form=form,
|
||||
again=bool(redirect_url),
|
||||
other_device=other_device,
|
||||
notify_env_is_dev=bool(notify_env == "development"),
|
||||
password_reset_url=password_reset_url,
|
||||
)
|
||||
|
||||
|
||||
@@ -6,15 +6,13 @@ from flask_login import current_user
|
||||
|
||||
from app.main import main
|
||||
|
||||
# import uuid
|
||||
|
||||
def _sign_out_at_login_dot_gov():
|
||||
# TODO this builds a url that will work correct if pasted into a browser, but returns a 404 if sent as a request
|
||||
base_url = "https://idp.int.identitysandbox.gov/openid_connect/logout?"
|
||||
client_id = f"client_id={os.getenv('LOGIN_DOT_GOV_CLIENT_ID')}"
|
||||
post_logout_redirect_uri = "post_logout_redirect_uri=http://localhost:6012/sign-in"
|
||||
|
||||
# TODO If I take this url and put it in the browser, login.gov sign out works properly
|
||||
# TODO But with this code it results in a 404 error message and we don't sign out from login.gov
|
||||
url = f"{base_url}{client_id}&{post_logout_redirect_uri}"
|
||||
current_app.logger.info(f"url={url}")
|
||||
response = requests.post(url, headers={"User-Agent": "Custom"})
|
||||
@@ -25,6 +23,7 @@ def _sign_out_at_login_dot_gov():
|
||||
def sign_out():
|
||||
# An AnonymousUser does not have an id
|
||||
if current_user.is_authenticated:
|
||||
current_user.sign_out()
|
||||
# TODO This doesn't work yet, due to problems above.
|
||||
_sign_out_at_login_dot_gov()
|
||||
current_user.sign_out()
|
||||
return redirect(url_for("main.index"))
|
||||
|
||||
Reference in New Issue
Block a user