notify-admin-338 login.gov integration

This commit is contained in:
Kenneth Kehl
2023-11-02 14:10:22 -07:00
parent 1d790868f3
commit e5403a52f1
6 changed files with 248 additions and 138 deletions
+3 -4
View File
@@ -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"))