-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev/sso login ux #608
Open
vaimdev
wants to merge
27
commits into
master
Choose a base branch
from
dev/sso_login_ux
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Dev/sso login ux #608
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
89f3d5b
fix (typecheck): fix typecheck issue
vaimdev cdeaf63
Merge branch 'master' into dev/sso_login_ux
vaimdev dbad147
feat: Add databricks helper class and functions
vaimdev 799e93b
fix (refresh token, lint): Fix refresh token and lint issue
vaimdev e1737d8
fix (lint): fix lint issue
vaimdev caa7809
fix (databricks helper): fix missing function definition
vaimdev 71c5eb1
fix (databricks helpers): fix function call namespace
vaimdev c187ead
wip (sso logic): Add SSO flow token verification in plot function, wh…
vaimdev 412e944
wip (sso): fix whether to throw exception when fail to get token
vaimdev 9283e8a
wip (sso): fix message display logic
vaimdev be26dee
fix (sso): fix flow
vaimdev 5ea4841
fix (sso): fix display message flow
vaimdev 8a482b5
fix (sso): Graph is not shown in dashboard due to only the first HTML…
vaimdev ab2794c
wip (sso): fix syntax error
vaimdev 5b35284
wip (sso): debugging code
vaimdev 8355b0f
wip (debug): add debug print
vaimdev 1a2ab33
wip (fix): syntax error
vaimdev a536648
wip (debug):debugging print
vaimdev dd29430
wip (debug): debugging print
vaimdev 36fcfea
wip (sso): attempt to display error in iframe
vaimdev 4820620
wip (databricks): return error msg html in the case of plot with inva…
vaimdev 2d6ad0b
wip (sso): display html message before throw exception
vaimdev 05d0dff
wip(sso): fix error
vaimdev fd46826
wip (sso): fix syntax error
vaimdev 4816fd6
wip (sso): clean up code
vaimdev bff2459
Update docstr for new/updated methods
sabizmil 4b0b129
fix (lint): fix lint issue
vaimdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -406,6 +406,8 @@ def refresh(token=None, fail_silent=False): | |
logger.debug("2. @PyGraphistry refresh :relogin") | ||
if isinstance(e, TokenExpireException): | ||
print("Token is expired, you need to relogin") | ||
PyGraphistry._config['api_token'] = None | ||
PyGraphistry._is_authenticated = False | ||
return PyGraphistry.relogin() | ||
|
||
if not fail_silent: | ||
|
@@ -2448,6 +2450,72 @@ def _handle_api_response(response): | |
|
||
|
||
|
||
# Databricks Dashboard SSO helper functions | ||
|
||
class DatabricksHelper(): | ||
|
||
@staticmethod | ||
def sso_repeat_get_token(repeat, wait): | ||
time.sleep(wait) | ||
|
||
for i in range(repeat): | ||
token = PyGraphistry.sso_get_token() | ||
if token: | ||
return token | ||
time.sleep(2) | ||
|
||
return | ||
|
||
@staticmethod | ||
def databricks_sso_wait_for_token(repeat=5, wait=20): | ||
from IPython.display import display, HTML | ||
if not PyGraphistry.api_token(): | ||
msg_html = '<br /><strong> .... </strong>' | ||
if not PyGraphistry.DatabricksHelper.sso_repeat_get_token(repeat, wait): | ||
msg_html = f'{msg_html}<br /><strong>Failed to get token after {repeat} .... </strong>' | ||
raise Exception(f"Failed to get token after {repeat} retries") | ||
msg_html = f'{msg_html}<br /><strong>Got token</strong>' | ||
display(HTML(msg_html)) | ||
else: | ||
display(HTML('<br /><strong>Token is valid, no waiting required.</strong>')) | ||
|
||
@staticmethod | ||
def databricks_sso_login_init(wait=20): | ||
from IPython.display import display, HTML, clear_output | ||
|
||
def init_login(wait): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. un-nest |
||
clear_output() | ||
token = PyGraphistry.api_token() | ||
if token: | ||
is_valid = PyGraphistry.verify_token() | ||
if not is_valid: | ||
print("***********token not valid, refresh token*****************") | ||
display(HTML('<br /><strong>Refresh token ....</strong>')) | ||
try: | ||
PyGraphistry.refresh() | ||
except Exception: | ||
pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this error case handling may need thinking? |
||
|
||
else: | ||
print("Token is still valid") | ||
display(HTML('<br /><strong>Token is still valid ....</strong>')) | ||
|
||
else: | ||
print("***********Prepare to sign in*****************") | ||
|
||
msg_html = f'<br /><strong>Prepare to sign in ....</strong><br><strong>Please Login with the link appear later. Waiting for success login for {wait} seconds, please login within {wait} seconds....</strong><br /><strong>Please close the browser tab and come back to dashboard....</strong>' | ||
|
||
display(HTML(msg_html)) | ||
init_login(wait) | ||
|
||
|
||
@staticmethod | ||
def databricks_sso_login(server="hub.graphistry.com", org_name=None, idp_name=None, retry=5, wait=20): | ||
from IPython.display import clear_output | ||
clear_output() | ||
if not PyGraphistry.api_token(): | ||
PyGraphistry.register(api=3, protocol="https", server=server, is_sso_login=True, org_name=org_name, idp_name=idp_name, sso_timeout=None, sso_opt_into_type="display") | ||
|
||
|
||
client_protocol_hostname = PyGraphistry.client_protocol_hostname | ||
store_token_creds_in_memory = PyGraphistry.store_token_creds_in_memory | ||
|
@@ -2501,6 +2569,10 @@ def _handle_api_response(response): | |
personal_key_secret = PyGraphistry.personal_key_secret | ||
switch_org = PyGraphistry.switch_org | ||
|
||
# databricks dashboard helper functions | ||
databricks_sso_wait_for_token = PyGraphistry.DatabricksHelper.databricks_sso_wait_for_token | ||
databricks_sso_login_init = PyGraphistry.DatabricksHelper.databricks_sso_login_init | ||
databricks_sso_login = PyGraphistry.DatabricksHelper.databricks_sso_login | ||
|
||
|
||
class NumpyJSONEncoder(json.JSONEncoder): | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public methods should have .rst-friendly docstrs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, we're trying to make all new code mypy-typed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, noted. I will add them in.