Skip to content

Commit

Permalink
Merge pull request #5390 from hamilton-earthscope/earthscope-sdk-env
Browse files Browse the repository at this point in the history
new: additional oauth2 config for earthscope-sdk support
  • Loading branch information
yuvipanda authored Jan 16, 2025
2 parents 7a7ae68 + 7c129bf commit 1aeae2c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions config/clusters/earthscope/common.values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ basehub:
001-username-claim: |
from oauthenticator.generic import GenericOAuthenticator
from traitlets import List, Unicode
from urllib.parse import urlparse
class CustomGenericOAuthenticator(GenericOAuthenticator):
# required_scopes functionality comes in from https://github.com/jupyterhub/oauthenticator/pull/719
Expand Down Expand Up @@ -94,10 +95,18 @@ basehub:
# For our deployment-service-check health check user, there is no auth_state.
# So these env variables need not be set.
if auth_state:
url_parts = urlparse(spawner.authenticator.token_url)
base_url = f"{url_parts.scheme}://{url_parts.netloc}"
scope_str = " ".join(spawner.authenticator.scope)
token_env = {
'AUTH0_ACCESS_TOKEN': auth_state.get("access_token", ""),
'AUTH0_ID_TOKEN': auth_state.get("id_token", ""),
'AUTH0_REFRESH_TOKEN': auth_state.get('refresh_token', '')
'ES_OAUTH2__AUDIENCE': spawner.authenticator.extra_authorize_params.get("audience", ""),
'ES_OAUTH2__CLIENT_ID': spawner.authenticator.client_id,
'ES_OAUTH2__DOMAIN': base_url,
'ES_OAUTH2__SCOPE': scope_str,
'ES_OAUTH2__ACCESS_TOKEN': auth_state.get("access_token", ""),
'ES_OAUTH2__ID_TOKEN': auth_state.get("id_token", ""),
'ES_OAUTH2__REFRESH_TOKEN': auth_state.get('refresh_token', '')
}
spawner.environment.update(token_env)
Expand Down

0 comments on commit 1aeae2c

Please sign in to comment.