improve custom scope docstrings

This commit is contained in:
Min RK
2022-03-16 08:35:59 +01:00
parent d2eaf90df2
commit 9a87b59e84
3 changed files with 8 additions and 5 deletions

View File

@@ -160,7 +160,7 @@ c.JupyterHub.load_roles = [
"groups": ["graders"], "groups": ["graders"],
"scopes": [ "scopes": [
"custom:myservice:read", "custom:myservice:read",
access:service!service=myservice, "access:service!service=myservice",
], ],
}, },
# instructors have read and write access to the service # instructors have read and write access to the service
@@ -169,7 +169,7 @@ c.JupyterHub.load_roles = [
"groups": ["instructors"], "groups": ["instructors"],
"scopes": [ "scopes": [
"custom:myservice:write", "custom:myservice:write",
access:service!service=myservice, "access:service!service=myservice",
], ],
}, },
] ]

View File

@@ -2039,7 +2039,7 @@ class JupyterHub(Application):
db.commit() db.commit()
async def init_role_creation(self): async def init_role_creation(self):
"""Load default and user-defined roles into the database""" """Load default and user-defined roles and scopes into the database"""
if self.custom_scopes: if self.custom_scopes:
self.log.info(f"Defining {len(self.custom_scopes)} custom scopes.") self.log.info(f"Defining {len(self.custom_scopes)} custom scopes.")
scopes.define_custom_scopes(self.custom_scopes) scopes.define_custom_scopes(self.custom_scopes)

View File

@@ -652,6 +652,8 @@ Scopes may not end with a hyphen or colon.
def define_custom_scopes(scopes): def define_custom_scopes(scopes):
"""Define custom scopes """Define custom scopes
Adds custom scopes to the scope_definitions dict.
Scopes must start with `custom:`. Scopes must start with `custom:`.
It is recommended to name custom scopes with a pattern like:: It is recommended to name custom scopes with a pattern like::
@@ -663,7 +665,8 @@ def define_custom_scopes(scopes):
That makes them easy to parse and avoids collisions across projects. That makes them easy to parse and avoids collisions across projects.
All scopes must have at least a `definition`, `scopes` must have at least one scope definition,
and each scope definition must have a `description`,
which will be displayed on the oauth authorization page, which will be displayed on the oauth authorization page,
and _may_ have a `subscopes` list of other scopes if having one scope and _may_ have a `subscopes` list of other scopes if having one scope
should imply having other, more specific scopes. should imply having other, more specific scopes.
@@ -673,7 +676,7 @@ def define_custom_scopes(scopes):
scopes: dict scopes: dict
A dictionary of scope definitions. A dictionary of scope definitions.
The keys are the scopes, The keys are the scopes,
while the values are dictionaries with at least a `definition` field, while the values are dictionaries with at least a `description` field,
and optional `subscopes` field. and optional `subscopes` field.
%s %s
Examples:: Examples::