fspijkerman / dash-okta-auth Goto Github PK
View Code? Open in Web Editor NEWDash Okta Authentication
License: MIT License
Dash Okta Authentication
License: MIT License
currently, if a user has logged in okta but his session has expired, the dash app is not updated anymore as the calls to /_dash-... are receiving a redirect (302) they cannot manage.
I have hacked the following solution that appears to work:
dcc.Location(refresh=True, id="URL_OUT"),
in the app layout def login_request(self):
# send to okta auth page
return redirect(url_for("okta.login"))
to
def login_request(self):
# send to okta auth page
if request.path.startswith("/_dash-update-component"):
import json
return json.dumps({"response": {"URL_OUT": {"href": "http://127.0.0.1:8051/login/okta"}}, "multi": True})
return redirect(url_for("okta.login"))
Today, the ID of the dcc.Location is hardcoded but it could be passed as a configuration parameter.
Is this a reasonable fix ?
I have the impression the library will, on every request, the wrapper calls is_authorized
which calls self.okta.session.get(f'{self.base_url}/userinfo')
(https://github.com/fspijkerman/dash-okta-auth/blob/master/dash_okta_auth/okta_oauth.py#L37) to retrieve the 'email' of the user. Is that correct ?
If so, it adds latency to each call just to get the email which is often already available in the JWT.
Is it possible to disable this call ?
i'm using a virtual env and installing from the requirements.txt file.
application will run if i remove auth='auth' but then I get an error from Okta:
"Description: The 'redirect_uri' parameter must be an absolute URI that is whitelisted in the client app settings."
I'm following https://github.com/okta/samples-python-flask/tree/master/okta-hosted-login
to set up the app on Okta (only difference a use of port 8050 for call back). The link to okta set up for flask-dance does not work btw.
any ideas?
thanks!!
The okta provider was removed in flask_dance. I was able to reuse most of your code replacing okta using the OAuth2ConsumerBlueprint.
You can find my demo application here: github.com/nicohein/dash-okta-oauth2
Let me know if you are interested in a pull request for your project. I haven't forked your project yet because I used a slightly different structure.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.