Skip to content

Commit

Permalink
refactor, globus: fix help string indentation and misc whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed Jun 26, 2023
1 parent 0bd5809 commit 2ade700
Showing 1 changed file with 34 additions and 23 deletions.
57 changes: 34 additions & 23 deletions oauthenticator/globus.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,24 @@ def _token_url_default(self):
)

identity_provider = Unicode(
help="""Restrict which institution a user
can use to login (GlobusID, University of Hogwarts, etc.). This should
be set in the app at developers.globus.org, but this acts as an additional
check to prevent unnecessary account creation."""
help="""
Restrict which institution (domain) a user can use to login (GlobusID,
University of Hogwarts, etc.). This should be set in the app at
developers.globus.org, but this acts as an additional check to prevent
unnecessary account creation.
"""
).tag(config=True)

def _identity_provider_default(self):
return os.getenv('IDENTITY_PROVIDER', '')

username_from_email = Bool(
False,
help="""Create username from email address, not preferred username. If
an identity provider is specified, email address must be from the same
domain. Email scope will be set automatically.""",
help="""
Create username from email address, not preferred username. If an
identity provider is specified, email address must be from the same
domain. Email scope will be set automatically.
""",
config=True,
)

Expand All @@ -115,8 +119,10 @@ def _username_claim_default(self):
return "preferred_username"

exclude_tokens = List(
help="""Exclude tokens from being passed into user environments
when they start notebooks, Terminals, etc."""
help="""
Exclude tokens from being passed into user environments when they start
notebooks, Terminals, etc.
"""
).tag(config=True)

def _exclude_tokens_default(self):
Expand All @@ -137,32 +143,40 @@ def _scope_default(self):
return scopes

globus_local_endpoint = Unicode(
help="""If Jupyterhub is also a Globus
endpoint, its endpoint id can be specified here."""
help="""
If JupyterHub is also a Globus endpoint, its endpoint id can be
specified here.
"""
).tag(config=True)

def _globus_local_endpoint_default(self):
return os.getenv('GLOBUS_LOCAL_ENDPOINT', '')

revoke_tokens_on_logout = Bool(
help="""Revoke tokens so they cannot be used again. Single-user servers
MUST be restarted after logout in order to get a fresh working set of
tokens."""
help="""
Revoke tokens so they cannot be used again. Single-user servers MUST be
restarted after logout in order to get a fresh working set of tokens.
"""
).tag(config=True)

def _revoke_tokens_on_logout_default(self):
return False

allowed_globus_groups = Set(
help="""Allow members of defined Globus Groups to access JupyterHub. Users in an
admin Globus Group are also automatically allowed. Groups are specified with their UUIDs. Setting this will
add the Globus Groups scope."""
help="""
Allow members of defined Globus Groups to access JupyterHub. Users in an
admin Globus Group are also automatically allowed. Groups are specified
with their UUIDs. Setting this will add the Globus Groups scope.
"""
).tag(config=True)

admin_globus_groups = Set(
help="""Set members of defined Globus Groups as JupyterHub admin users.
These users are automatically allowed to login to JupyterHub. Groups are specified with
their UUIDs. Setting this will add the Globus Groups scope."""
help="""
Set members of defined Globus Groups as JupyterHub admin users. These
users are automatically allowed to login to JupyterHub. Groups are
specified with their UUIDs. Setting this will add the Globus Groups
scope.
"""
).tag(config=True)

async def pre_spawn_start(self, user, spawner):
Expand Down Expand Up @@ -208,7 +222,6 @@ def build_auth_state_dict(self, token_info, user_info):
accounts) will correspond to a Globus User ID, so [email protected]
will have the 'foouser' account in Jupyterhub.
"""

tokens = self.get_globus_tokens(token_info)
# historically, tokens have been organized by resource server for convenience.
# If multiple scopes are requested from the same resource server, they will be
Expand Down Expand Up @@ -324,7 +337,6 @@ def user_info_to_username(self, user_info):
accounts) will correspond to a Globus User ID, so [email protected]
will have the 'foouser' account in Jupyterhub.
"""

return user_info.get(self.username_claim).split('@')[0]

def get_default_headers(self):
Expand Down Expand Up @@ -352,7 +364,6 @@ async def revoke_service_tokens(self, services):
<Additional services>...
}
"""

access_tokens = [
token_dict.get('access_token') for token_dict in services.values()
]
Expand Down

0 comments on commit 2ade700

Please sign in to comment.