Skip to content

Commit 8a5fc80

Browse files
committed
examples/service-whoami-flask: Add scope to user role
For ordinary users to access the service, they need an appropriate scope added to the user role. This adds that role in the jupyterhub_config.py, as well as a note about this in the README. It also updates the ouptut that comes form the whoami service.
1 parent cc9d9e4 commit 8a5fc80

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

examples/service-whoami-flask/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@ After logging in with your local-system credentials, you should see a JSON dump
1515
```json
1616
{
1717
"admin": false,
18-
"last_activity": "2016-05-27T14:05:18.016372",
18+
"groups": [],
19+
"kind": "user",
1920
"name": "queequeg",
20-
"pending": null,
21-
"server": "/user/queequeg"
21+
"scopes": [
22+
"access:services!service=whoami",
23+
"read:users:groups!user=queequeg",
24+
"read:users:name!user=queequeg"
25+
],
26+
"session_id": "a32e59cdd7b445759c58c48e47394a38"
2227
}
2328
```
2429

25-
This relies on the Hub starting the whoami service, via config (see [jupyterhub_config.py](./jupyterhub_config.py)).
30+
This relies on the Hub starting the whoami service, via config (see [jupyterhub_config.py](./jupyterhub_config.py)). For ordinary users to access this service, they need to be given the appropriate scope (again, see [jupyterhub_config.py](./jupyterhub_config.py)).
2631

2732
A similar service could be run externally, by setting the JupyterHub service environment variables:
2833

examples/service-whoami-flask/jupyterhub_config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
'environment': {'FLASK_APP': 'whoami-flask.py'},
77
},
88
]
9+
c.JupyterHub.load_roles = [
10+
{
11+
'name': 'user',
12+
'scopes': [
13+
'access:services!service=whoami',
14+
'self'
15+
]
16+
}
17+
]
918

1019
# dummy auth and simple spawner for testing
1120
# any username and password will work

0 commit comments

Comments
 (0)