Add OIDC Authorization
This commit is contained in:
parent
4b49def86d
commit
f6d2373f39
@ -30,7 +30,7 @@ from dash import Dash, html, dcc, callback, Output, Input, State, no_update
|
||||
from waitress import serve
|
||||
from flask_caching import Cache
|
||||
from dash.exceptions import PreventUpdate
|
||||
import dash_auth
|
||||
from dash_auth import OIDCAuth
|
||||
import yahoo_fin.stock_info as si
|
||||
import hashlib
|
||||
from dotenv import load_dotenv
|
||||
@ -551,23 +551,33 @@ def intelligent_loop_plots(sym, stk_data):
|
||||
|
||||
return data, vol.to_frame('_VOL'), macd, rsi, plot_indicator
|
||||
|
||||
VALID_USERNAME_PASSWORD_PAIRS = {
|
||||
'ce16559af2caf7bb54bebd57a1602e29ada331b3356004265abeab0e568278cc':
|
||||
'b4db36eb3f887ca0bc15de7feb0b41a9589b65dbd5325aedf1c76b3ee63b8871'
|
||||
}
|
||||
# VALID_USERNAME_PASSWORD_PAIRS = {
|
||||
# 'ce16559af2caf7bb54bebd57a1602e29ada331b3356004265abeab0e568278cc':
|
||||
# 'b4db36eb3f887ca0bc15de7feb0b41a9589b65dbd5325aedf1c76b3ee63b8871'
|
||||
# }
|
||||
|
||||
def user_login(username, password):
|
||||
if VALID_USERNAME_PASSWORD_PAIRS.get(hash_password(username)) == hash_password(password):
|
||||
return True
|
||||
return False
|
||||
# def user_login(username, password):
|
||||
# if VALID_USERNAME_PASSWORD_PAIRS.get(hash_password(username)) == hash_password(password):
|
||||
# return True
|
||||
# return False
|
||||
|
||||
# Initialize the app
|
||||
app = Dash()
|
||||
dash_auth.BasicAuth(
|
||||
app,
|
||||
# VALID_USERNAME_PASSWORD_PAIRS,
|
||||
auth_func=user_login,
|
||||
secret_key="MK8dyS6PyDDuEuzrmqa7dJTJZ7eH2Jkh",
|
||||
app = Dash(__name__)
|
||||
|
||||
# dash_auth.BasicAuth(
|
||||
# app,
|
||||
# # VALID_USERNAME_PASSWORD_PAIRS,
|
||||
# auth_func=user_login,
|
||||
# secret_key="MK8dyS6PyDDuEuzrmqa7dJTJZ7eH2Jkh",
|
||||
# )
|
||||
|
||||
auth = OIDCAuth(app, secret_key=os.environ['SECRET_KEY'])
|
||||
auth.register_provider(
|
||||
"stock",
|
||||
token_endpoint_auth_method="client_secret_post",
|
||||
client_id=os.environ['APP_ID'],
|
||||
client_secret=os.environ['APP_SECRET'],
|
||||
server_metadata_url=os.environ['SERVER_URL'],
|
||||
)
|
||||
|
||||
watchlist = get_watchlist()
|
||||
|
@ -1,12 +1,15 @@
|
||||
appdirs==1.4.4
|
||||
Authlib==1.3.2
|
||||
beautifulsoup4==4.12.3
|
||||
blinker==1.8.2
|
||||
bs4==0.0.2
|
||||
cachelib==0.9.0
|
||||
certifi==2024.8.30
|
||||
cffi==1.17.1
|
||||
charset-normalizer==3.3.2
|
||||
click==8.1.7
|
||||
colorama==0.4.6
|
||||
cryptography==43.0.1
|
||||
cssselect==1.2.0
|
||||
dash==2.18.1
|
||||
dash-core-components==2.0.0
|
||||
@ -31,6 +34,7 @@ pandas==2.2.3
|
||||
parse==1.20.2
|
||||
plotly==5.24.1
|
||||
psycopg2==2.9.9
|
||||
pycparser==2.22
|
||||
pyee==11.1.1
|
||||
pyppeteer==2.0.0
|
||||
pyquery==2.0.1
|
||||
|
Loading…
x
Reference in New Issue
Block a user