Skip to content

Commit 7a67090

Browse files
authored
Merge pull request #3883 from yuvipanda/earthscope-generic
Allow restricting profiles & profile_options based on JupyterHub groups
2 parents d339a89 + b8a8e49 commit 7a67090

File tree

20 files changed

+403
-213
lines changed

20 files changed

+403
-213
lines changed

config/clusters/2i2c-aws-us/itcoocean.values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ jupyterhub:
248248
- display_name: "Bring your own image"
249249
description: Specify your own docker image (must have python and jupyterhub installed in it)
250250
slug: custom
251-
allowed_teams:
251+
allowed_groups:
252252
- Hackweek-ITCOocean:itcoocean-hackweek-2023
253253
- nmfs-opensci:2i2c-demo
254254
- 2i2c-org:hub-access-for-2i2c-staff

config/clusters/2i2c-aws-us/showcase.values.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ basehub:
5858
profileList:
5959
- display_name: "Magic Link Demo"
6060
description: "For demoing magic links"
61-
allowed_teams:
61+
allowed_groups:
6262
- 2i2c-community-showcase:magiclinks-demo
6363
kubespawner_override:
6464
image: pangeo/pangeo-notebook:2023.06.20
@@ -69,7 +69,7 @@ basehub:
6969
node.kubernetes.io/instance-type: r5.xlarge
7070
- display_name: "NASA TOPS-T ScienceCore-ClimateRisk"
7171
description: "For collaborative work on 2i2c/MD's NASA TOPS-T ScienceCore Module"
72-
allowed_teams:
72+
allowed_groups:
7373
- 2i2c-demo-hub-access:showcase-topst
7474
- 2i2c-org:hub-access-for-2i2c-staff
7575
- ScienceCore:climaterisk-team
@@ -82,7 +82,7 @@ basehub:
8282
node.kubernetes.io/instance-type: r5.xlarge
8383
- display_name: "NASA TOPS-T ScienceCore"
8484
description: "JupyterHubs for NASA ScienceCore Modules"
85-
allowed_teams:
85+
allowed_groups:
8686
- 2i2c-org:hub-access-for-2i2c-staff
8787
- ScienceCore:2i2c-showcase
8888
profile_options:
@@ -132,7 +132,7 @@ basehub:
132132
node.kubernetes.io/instance-type: r5.xlarge
133133
- display_name: "Shared Small: 1-4 CPU, 8-32 GB"
134134
description: "A shared machine, the recommended option until you experience a limitation."
135-
allowed_teams: &allowed_teams
135+
allowed_groups: &allowed_groups
136136
- 2i2c-org:hub-access-for-2i2c-staff
137137
- 2i2c-community-showcase:access-2i2c-showcase
138138
profile_options: &profile_options
@@ -188,7 +188,7 @@ basehub:
188188
- display_name: "Small: 4 CPU, 32 GB"
189189
description: "A dedicated machine for you."
190190
profile_options: *profile_options
191-
allowed_teams: *allowed_teams
191+
allowed_groups: *allowed_groups
192192
kubespawner_override:
193193
mem_guarantee: 28.937G
194194
cpu_guarantee: 0.4
@@ -199,7 +199,7 @@ basehub:
199199
- display_name: "Medium: 16 CPU, 128 GB"
200200
description: "A dedicated machine for you."
201201
profile_options: *profile_options
202-
allowed_teams: *allowed_teams
202+
allowed_groups: *allowed_groups
203203
kubespawner_override:
204204
mem_guarantee: 120.513G
205205
cpu_guarantee: 1.6
@@ -210,7 +210,7 @@ basehub:
210210
- display_name: "Large: 64 CPU, 512 GB"
211211
description: "A dedicated machine for you"
212212
profile_options: *profile_options
213-
allowed_teams: *allowed_teams
213+
allowed_groups: *allowed_groups
214214
kubespawner_override:
215215
mem_guarantee: 489.13G
216216
cpu_guarantee: 6.4
@@ -220,7 +220,7 @@ basehub:
220220

221221
- display_name: NVIDIA Tesla T4, ~16 GB, ~4 CPUs
222222
slug: gpu
223-
allowed_teams:
223+
allowed_groups:
224224
- 2i2c-org:hub-access-for-2i2c-staff
225225
description: "Start a container on a dedicated node with a GPU"
226226
profile_options:

config/clusters/earthscope/common.values.yaml

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ basehub:
3737
hub:
3838
extraConfig:
3939
001-username-claim: |
40-
from oauthenticator.auth0 import Auth0OAuthenticator
41-
from traitlets import List, Unicode, default
42-
from urllib.parse import urlencode
40+
from oauthenticator.generic import GenericOAuthenticator
41+
from traitlets import List, Unicode
4342
44-
class CustomAuth0OAuthenticator(Auth0OAuthenticator):
43+
class CustomGenericOAuthenticator(GenericOAuthenticator):
4544
# required_scopes functionality comes in from https://github.com/jupyterhub/oauthenticator/pull/719
4645
# Can be removed from here once that PR is merged
4746
required_scopes = List(
@@ -62,28 +61,6 @@ basehub:
6261
""",
6362
)
6463
65-
# Upstreamed at https://github.com/jupyterhub/oauthenticator/pull/722
66-
logout_redirect_to_url = Unicode(
67-
config=True,
68-
help="""
69-
Redirect to this URL after the user is logged out.
70-
71-
Must be explicitly added to the "Allowed Logout URLs" in the configuration
72-
for this Auth0 application. See https://auth0.com/docs/authenticate/login/logout/redirect-users-after-logout
73-
for more information.
74-
"""
75-
)
76-
77-
@default("logout_redirect_url")
78-
def _logout_redirect_url_default(self):
79-
url = f"https://{self.auth0_domain}/v2/logout"
80-
if self.logout_redirect_to_url:
81-
# If a redirectTo is set, we must also include the `client_id`
82-
# Auth0 expects `client_id` to be snake cased while `redirectTo` is camel cased
83-
params = urlencode({"client_id": self.client_id, "redirectTo": self.logout_redirect_to_url})
84-
url = f"{url}?{params}"
85-
return url
86-
8764
async def check_allowed(self, username, auth_model):
8865
if await super().check_allowed(username, auth_model):
8966
return True
@@ -99,6 +76,14 @@ basehub:
9976
10077
return False
10178
79+
async def authenticate(self, *args, **kwargs):
80+
resp = await super().authenticate(*args, **kwargs)
81+
# Setup groups to be same as list of scopes granted
82+
# This can go away after https://github.com/jupyterhub/oauthenticator/pull/735 is
83+
# merged
84+
resp["groups"] = resp["auth_state"]["scope"]
85+
return resp
86+
10287
def populate_token(spawner, auth_state):
10388
# For our deployment-service-check health check user, there is no auth_state.
10489
# So these env variables need not be set.
@@ -112,15 +97,13 @@ basehub:
11297
11398
c.Spawner.auth_state_hook = populate_token
11499
115-
c.JupyterHub.authenticator_class = CustomAuth0OAuthenticator
100+
c.JupyterHub.authenticator_class = CustomGenericOAuthenticator
116101
config:
117-
JupyterHub:
118-
authenticator_class: auth0
119-
CustomAuth0OAuthenticator:
102+
CustomGenericOAuthenticator:
120103
required_scopes:
121104
# This allows EarthScope to control who can login to the hub
122105
- geolab
123-
Auth0OAuthenticator:
106+
GenericOAuthenticator:
124107
scope:
125108
- openid
126109
# This gives us refresh token
@@ -130,10 +113,14 @@ basehub:
130113
# automatically granted this scope, so we can test. See
131114
# https://2i2c.freshdesk.com/a/tickets/1280 for how this was granted.
132115
- geolab
116+
- geolab:dev
117+
- geolab:power
133118
extra_authorize_params:
134119
# This isn't an actual URL, just a string. Must not have a trailing slash
135120
audience: https://api.dev.earthscope.org
136121
username_claim: sub
122+
# Convert 'scope' from the OAuth2 response into JupyterHub groups
123+
manage_groups: true
137124
CILogonOAuthenticator:
138125
allowed_idps:
139126
http://github.com/login/oauth/authorize:
@@ -152,6 +139,10 @@ basehub:
152139
profileList:
153140
- display_name: "Shared Small: 1-4 CPU, 8-32 GB"
154141
description: "A shared machine, the recommended option until you experience a limitation."
142+
allowed_groups:
143+
- geolab
144+
- geolab:dev
145+
- geolab:power
155146
profile_options: &profile_options
156147
image:
157148
display_name: Image
@@ -186,30 +177,36 @@ basehub:
186177
mem_limit: null
187178
node_selector:
188179
node.kubernetes.io/instance-type: r5.xlarge
189-
190180
- display_name: "Small: 4 CPU, 32 GB"
191181
description: "A dedicated machine for you."
182+
allowed_groups:
183+
- geolab
184+
- geolab:dev
185+
- geolab:power
192186
profile_options: *profile_options
193187
kubespawner_override:
194188
mem_guarantee: 28.937G
195189
cpu_guarantee: 0.4
196190
mem_limit: null
197191
node_selector:
198192
node.kubernetes.io/instance-type: r5.xlarge
199-
200193
- display_name: "Medium: 16 CPU, 128 GB"
201194
description: "A dedicated machine for you."
202195
profile_options: *profile_options
196+
allowed_groups:
197+
- geolab:dev
198+
- geolab:power
203199
kubespawner_override:
204200
mem_guarantee: 120.513G
205201
cpu_guarantee: 1.6
206202
mem_limit: null
207203
node_selector:
208204
node.kubernetes.io/instance-type: r5.4xlarge
209-
210205
- display_name: "Large: 64 CPU, 512 GB"
211206
description: "A dedicated machine for you"
212207
profile_options: *profile_options
208+
allowed_groups:
209+
- geolab:power
213210
kubespawner_override:
214211
mem_guarantee: 489.13G
215212
cpu_guarantee: 6.4

config/clusters/earthscope/enc-prod.secret.values.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ basehub:
22
jupyterhub:
33
hub:
44
config:
5-
Auth0OAuthenticator:
6-
client_id: ENC[AES256_GCM,data:qn8Xel6vzFKHuL7gP8aGKQr3C7AGORQ7sCyNvKulbDE=,iv:bWYt/w31HcaEDjUBW3DZv/Lb4Ny/BPEjoBTsjp0XP6g=,tag:/02E1lYfhfOMcd+P2+DV8Q==,type:str]
7-
client_secret: ENC[AES256_GCM,data:qry2vIkYLTRd7rlg6RTO6pB+e4SP5mvzClqagyJbbzXYkdeiGQccVFsERQ15RT/BRDX/PX4Bj5ZxcuCY9wGsxw==,iv:k763ow53AuqWG7dSyqkaosa9O4NwufRnmmORRxssGQA=,tag:MX4zqeOS3vdxhhYUljipJA==,type:str]
5+
GenericOAuthenticator:
6+
client_id: ENC[AES256_GCM,data:+ctWM1MpyksEjMLTnVZAw+N0Wv6ZNXL+fHdeamt64Ow=,iv:1KBoaNQTaUmyAt1wAO9pmvOkoLCl+B2eCBIu3SsRKYA=,tag:sK3EmbdSJP3UldX51274xA==,type:str]
7+
client_secret: ENC[AES256_GCM,data:UtnmnF84dQ50h741JNvLmfBkzoI6ui16YVV8tRh1GXyCIrcu5bgy5StRIIjw3uRVo7g7bFFdGN6lIeQIUVd+Pw==,iv:arvQ5RbKiHFFNdyksmIA9UVoHWRdXgeKAhDGPPE7qrU=,tag:2NdZqXXBpEIUhrA3oTnKPw==,type:str]
88
sops:
99
kms: []
1010
gcp_kms:
@@ -14,8 +14,8 @@ sops:
1414
azure_kv: []
1515
hc_vault: []
1616
age: []
17-
lastmodified: "2024-02-01T19:48:36Z"
18-
mac: ENC[AES256_GCM,data:Cw3rTUGqQlymWXXu/Z7qLSAIlULn5B3SAPxbzkeBDCFSO8u4fhuZXEjoEBvFFdujdEtU9Q7bASKRyl4aveZDJ+aZHboKNDV77d7atONojcEFj/DIy2ELQriMwyq1hx5hZS/onGgt8XLmcjXDJdMH6zEZOYrZl93uTuoS+Qt+4GI=,iv:oCWMr+17mgo+P1btrLglokBO3yYZ9JpZBTx36Vhtb3s=,tag:GEN4T0/9KQzz4+oTxvhbBQ==,type:str]
17+
lastmodified: "2024-03-29T23:50:57Z"
18+
mac: ENC[AES256_GCM,data:h9pUWffgf8vBqG4timmCMharFGj1jdP8iSaaczx1GfzouUG+hhlG82OQTFVSmLwhHkzlmxJxw+t7gi6Zwx9nNgVVfnwa4Qhw6V/XWrBRr8gre2I9+MuXXeYOcjiDqIyasF0TYxGW/kvLZ6+khGvi4iIhnk9rJOk/LpFhpj7IthQ=,iv:1yIFhnW1Mv+d5bBKFGgpMDCCt5zPGfP9YekGey4KF/g=,tag:YgXBpr03lP5q9y1sJ2CsUA==,type:str]
1919
pgp: []
2020
unencrypted_suffix: _unencrypted
21-
version: 3.7.3
21+
version: 3.8.1

config/clusters/earthscope/enc-staging.secret.values.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ basehub:
22
jupyterhub:
33
hub:
44
config:
5-
Auth0OAuthenticator:
6-
client_id: ENC[AES256_GCM,data:urLrYypX6IUSVpqFAumEAi9aGJKyQv8oQuNqw5HNhKo=,iv:sQcq2R5wbS2P00nygxPQ3p2LdAsxkRQrk4jvnMWAjQg=,tag:eosLpXx6vWQMNjIxDcsC7Q==,type:str]
7-
client_secret: ENC[AES256_GCM,data:PrphM7gVSfUOInO008VgfhNU4r1+I4oLRT+ypJv5848Bvy1nN+ARzTrPgu7Q3KIiCaXyfNd3Xv6ieb0lsKCLZw==,iv:Vnbo4jG0sARtOL28GxgGAKKITQb5Tx6/TNscWUNgkJU=,tag:RgxhqVzdfsmwMTTEMCn2Zw==,type:str]
5+
GenericOAuthenticator:
6+
client_id: ENC[AES256_GCM,data:Rpa6XhJLmHBkccOZM58T0IwcviJvc2+jbLbL3LDQxgI=,iv:57//hbKbkT8PDa1kanOoS4wlWLvc1hp8fyGgMMaUKzk=,tag:zyv29aa/M7cqar2izZDRTg==,type:str]
7+
client_secret: ENC[AES256_GCM,data:w7feSVDwFN0mbxvLH1DEpw/eanx5+vJXZ7JPSTkVxIAm0aZod4H7lhlEy/gmMgPUJfBF32tXPrrYh6Z5E83oIQ==,iv:RQt6NCiDwAwn15XGxF7T+DVdYck0kw/hKEV9ULgxY1k=,tag:BRnwMh76yaMF7RyKPhBd/g==,type:str]
88
sops:
99
kms: []
1010
gcp_kms:
@@ -14,8 +14,8 @@ sops:
1414
azure_kv: []
1515
hc_vault: []
1616
age: []
17-
lastmodified: "2024-02-01T19:48:31Z"
18-
mac: ENC[AES256_GCM,data:ZYVgv+u0FD+jxYtgyITNLXr5bHNEEkkXtTM0SJGv8txbAVM4yt1k9CF95iVevPsRGG2yztY5vTDQaFGeg0tLGmG55fuuliZhMrB9RsDkmM3qEibVgQQTQZI5ZUciWHSBGm/NCMKnj6ujIx0h3E3cjtZBESIpONH+66kbuGhAlMo=,iv:ORwgid7PCff05bxWN9FuWNCN+wLY+bVZi0GfGDZwQj4=,tag:O+Bkh0UbeDzmAvYWJ5PpKQ==,type:str]
17+
lastmodified: "2024-03-29T23:43:10Z"
18+
mac: ENC[AES256_GCM,data:OnvUNbNHox7iF98w1aJSnrFJ1C3FSD+dz/l7ZK1z5uBnJAyhX3FhVoDGmA3TWAtS5U+ebiz8RbbVjJ/ge687ke2dL/Lnd9Ueay2tsF4ac1BYF6i5LqqsHqzaPwkrRVazB1aRgKx/O37Plm8KuAg2o9dN8jGtjnnSlbIxgJuJIUQ=,iv:Eo0iQ6qrbbcUkPFHzBwuMBGi1fCYnVWLPkkn9GQfrig=,tag:iUbwcWtat7qkfNE5i5MU6A==,type:str]
1919
pgp: []
2020
unencrypted_suffix: _unencrypted
21-
version: 3.7.3
21+
version: 3.8.1

config/clusters/earthscope/prod.values.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ basehub:
1212
name: "EarthScope"
1313
hub:
1414
config:
15-
CustomAuth0OAuthenticator:
16-
logout_redirect_to_url: https://geolab.earthscope.cloud
17-
Auth0OAuthenticator:
18-
auth0_domain: login.earthscope.org
15+
GenericOAuthenticator:
16+
token_url: https://login.earthscope.org/oauth/token
17+
authorize_url: https://login.earthscope.org/authorize
18+
userdata_url: https://login.earthscope.org/userinfo
19+
logout_redirect_url: https://login.earthscope.org/v2/logout?client_id=2PbhUTbRU6e7uIaaEZIShotx15MbvsJJ
1920
extra_authorize_params:
2021
# This isn't an actual URL, just a string. Must not have a trailing slash
2122
audience: https://api.earthscope.org

config/clusters/earthscope/staging.values.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ basehub:
1313
name: "EarthScope staging"
1414
hub:
1515
config:
16-
CustomAuth0OAuthenticator:
17-
logout_redirect_to_url: https://staging.geolab.earthscope.cloud
18-
Auth0OAuthenticator:
19-
auth0_domain: login-dev.earthscope.org
16+
GenericOAuthenticator:
17+
token_url: https://login-dev.earthscope.org/oauth/token
18+
authorize_url: https://login-dev.earthscope.org/authorize
19+
userdata_url: https://login-dev.earthscope.org/userinfo
20+
logout_redirect_url: https://login-dev.earthscope.org/v2/logout?client_id=Kn6kSKtw9TqgrSrEmDS0rlBM7Sc69BkL
2021
extra_authorize_params:
2122
# This isn't an actual URL, just a string. Must not have a trailing slash
2223
audience: https://api.dev.earthscope.org

config/clusters/leap/common.values.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ basehub:
132132
description: &profile_list_description "Start a container limited to a chosen share of capacity on a node of this type"
133133
slug: medium-full
134134
default: true
135-
allowed_teams:
135+
allowed_groups:
136136
- 2i2c-org:hub-access-for-2i2c-staff
137137
- leap-stc:leap-pangeo-full-access
138138
profile_options:
@@ -235,13 +235,13 @@ basehub:
235235

236236
# NOTE: This is the second medium profile list entry, with less node
237237
# share options for a different subset of users via the basehub
238-
# specific allowed_teams configuration.
238+
# specific allowed_groups configuration.
239239
#
240240
- display_name: "CPU only"
241241
description: *profile_list_description
242242
slug: medium-base
243243
default: true
244-
allowed_teams:
244+
allowed_groups:
245245
- leap-stc:leap-pangeo-base-access
246246
profile_options:
247247
requests:
@@ -262,7 +262,7 @@ basehub:
262262
- display_name: GPU
263263
slug: gpu
264264
description: NVIDIA Tesla T4, 24GB RAM, 8 CPUs
265-
allowed_teams:
265+
allowed_groups:
266266
- 2i2c-org:hub-access-for-2i2c-staff
267267
- leap-stc:leap-pangeo-full-access
268268
profile_options:

config/clusters/meom-ige/common.values.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ basehub:
4545
#
4646
# - display_name: Grenoble demo
4747
# default: true
48-
# allowed_teams:
48+
# allowed_groups:
4949
# - 2i2c-org:hub-access-for-2i2c-staff
5050
# - meom-group:hub-users # long term users
5151
# - demo-dask-grenoble2023:demo # temporary users for event
@@ -93,7 +93,7 @@ basehub:
9393
# RAM on a node, not total node capacity
9494
- display_name: "Small"
9595
default: true
96-
allowed_teams: &allowed_teams_normal_use
96+
allowed_groups: &allowed_groups_normal_use
9797
- 2i2c-org:hub-access-for-2i2c-staff
9898
- meom-group:hub-users # long term users
9999
description: "~2 CPU, ~8G RAM"
@@ -103,31 +103,31 @@ basehub:
103103
node_selector:
104104
node.kubernetes.io/instance-type: n1-standard-2
105105
- display_name: "Medium"
106-
allowed_teams: *allowed_teams_normal_use
106+
allowed_groups: *allowed_groups_normal_use
107107
description: "~8 CPU, ~32G RAM"
108108
kubespawner_override:
109109
mem_limit: 32G
110110
mem_guarantee: 22G
111111
node_selector:
112112
node.kubernetes.io/instance-type: n1-standard-8
113113
- display_name: "Large"
114-
allowed_teams: *allowed_teams_normal_use
114+
allowed_groups: *allowed_groups_normal_use
115115
description: "~16 CPU, ~64G RAM"
116116
kubespawner_override:
117117
mem_limit: 64G
118118
mem_guarantee: 47G
119119
node_selector:
120120
node.kubernetes.io/instance-type: n1-standard-16
121121
- display_name: "Very Large"
122-
allowed_teams: *allowed_teams_normal_use
122+
allowed_groups: *allowed_groups_normal_use
123123
description: "~32 CPU, ~128G RAM"
124124
kubespawner_override:
125125
mem_limit: 128G
126126
mem_guarantee: 100G
127127
node_selector:
128128
node.kubernetes.io/instance-type: n1-standard-32
129129
- display_name: "Huge"
130-
allowed_teams: *allowed_teams_normal_use
130+
allowed_groups: *allowed_groups_normal_use
131131
description: "~64 CPU, ~256G RAM"
132132
kubespawner_override:
133133
mem_limit: 256G

0 commit comments

Comments
 (0)