mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 22:13:00 +00:00
Make role_associations
private again
This commit is contained in:
@@ -2342,7 +2342,7 @@ class JupyterHub(Application):
|
|||||||
if self.authenticator.reset_managed_roles_on_startup:
|
if self.authenticator.reset_managed_roles_on_startup:
|
||||||
for kind in kinds:
|
for kind in kinds:
|
||||||
entity_name = kind[:-1]
|
entity_name = kind[:-1]
|
||||||
association_class = orm.role_associations[entity_name]
|
association_class = orm._role_associations[entity_name]
|
||||||
deleted = (
|
deleted = (
|
||||||
db.query(association_class)
|
db.query(association_class)
|
||||||
.filter(association_class.managed_by_auth == True)
|
.filter(association_class.managed_by_auth == True)
|
||||||
|
@@ -163,7 +163,7 @@ class Server(Base):
|
|||||||
# lots of things have roles
|
# lots of things have roles
|
||||||
# mapping tables are the same for all of them
|
# mapping tables are the same for all of them
|
||||||
|
|
||||||
role_associations = {}
|
_role_associations = {}
|
||||||
|
|
||||||
for entity in (
|
for entity in (
|
||||||
'user',
|
'user',
|
||||||
@@ -186,7 +186,7 @@ for entity in (
|
|||||||
Column('managed_by_auth', Boolean, default=False),
|
Column('managed_by_auth', Boolean, default=False),
|
||||||
)
|
)
|
||||||
|
|
||||||
role_associations[entity] = type(
|
_role_associations[entity] = type(
|
||||||
entity.title() + 'RoleMap', (Base,), {'__table__': table}
|
entity.title() + 'RoleMap', (Base,), {'__table__': table}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -268,7 +268,7 @@ def grant_role(db, entity, role, managed=False, commit=True):
|
|||||||
enitity_name = type(entity).__name__.lower()
|
enitity_name = type(entity).__name__.lower()
|
||||||
entity.roles.append(role)
|
entity.roles.append(role)
|
||||||
if managed:
|
if managed:
|
||||||
association_class = orm.role_associations[enitity_name]
|
association_class = orm._role_associations[enitity_name]
|
||||||
association = (
|
association = (
|
||||||
db.query(association_class)
|
db.query(association_class)
|
||||||
.filter(
|
.filter(
|
||||||
|
@@ -761,7 +761,7 @@ async def test_auth_manage_roles_marks_new_assignment_as_managed(app, user, role
|
|||||||
with mock.patch.dict(app.tornado_settings, {"authenticator": authenticator}):
|
with mock.patch.dict(app.tornado_settings, {"authenticator": authenticator}):
|
||||||
await app.login_user(user.name)
|
await app.login_user(user.name)
|
||||||
assert not app.db.dirty
|
assert not app.db.dirty
|
||||||
UserRoleMap = orm.role_associations['user']
|
UserRoleMap = orm._role_associations['user']
|
||||||
association = (
|
association = (
|
||||||
app.db.query(UserRoleMap)
|
app.db.query(UserRoleMap)
|
||||||
.filter((UserRoleMap.role_id == role.id) & (UserRoleMap.user_id == user.id))
|
.filter((UserRoleMap.role_id == role.id) & (UserRoleMap.user_id == user.id))
|
||||||
|
Reference in New Issue
Block a user