revert SSO changes
This commit is contained in:
+4
-11
@@ -2,7 +2,6 @@ import streamlit as st
|
||||
import msal
|
||||
import requests
|
||||
import boto3
|
||||
import secrets
|
||||
from botocore.exceptions import ClientError
|
||||
import json
|
||||
|
||||
@@ -58,11 +57,7 @@ app = msal.ConfidentialClientApplication(CLIENT_ID, authority=AUTHORITY, client_
|
||||
|
||||
|
||||
def get_auth_url(REDIRECT_URI):
|
||||
#Generates a random stat parameter
|
||||
state = secrets.token_urlsafe(16)
|
||||
#Stores the state param in the session state
|
||||
st.session_state['state'] = state
|
||||
auth_url = app.get_authorization_request_url(SCOPE, redirect_uri=REDIRECT_URI, state=state)
|
||||
auth_url = app.get_authorization_request_url(SCOPE, redirect_uri=REDIRECT_URI )
|
||||
return auth_url
|
||||
|
||||
@st.cache_data
|
||||
@@ -80,13 +75,11 @@ def get_user_info(access_token):
|
||||
|
||||
def handle_redirect(REDIRECT_URI):
|
||||
if not st.session_state.get('access_token'):
|
||||
query_params = st.experimental_get_query_params()
|
||||
code = st.query_params.get('code')
|
||||
state=query_params.get('state')
|
||||
if code and state and state[0] == st.session_state.get('state'):
|
||||
access_token = get_token_from_code(code[0], REDIRECT_URI)
|
||||
if code:
|
||||
access_token = get_token_from_code(code, REDIRECT_URI)
|
||||
st.session_state['access_token'] = access_token
|
||||
clear_url()
|
||||
st.session_state
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user