Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Paste
P1029
(An Untitled Masterwork)
Active
Public
Actions
Authored by
anlambert
on Apr 28 2021, 4:25 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
#!/usr/bin/env python3
# Copyright (C) 2020-2021 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
from
keycloak
import
KeycloakAdmin
SERVER_URL
=
"https://auth.softwareheritage.org/auth/"
REALM_NAME
=
"SoftwareHeritage"
ADMIN
=
{
"username"
:
"anlambert"
,
"password"
:
"***"
}
# login as admin in swh realm
KEYCLOAK_ADMIN
=
KeycloakAdmin
(
SERVER_URL
,
ADMIN
[
"username"
],
ADMIN
[
"password"
],
REALM_NAME
)
roles
=
[]
for
role
in
[
"offline_access"
,
"uma_authorization"
]:
realm_role
=
KEYCLOAK_ADMIN
.
get_realm_role
(
role
)
roles
.
append
(
realm_role
)
for
user
in
KEYCLOAK_ADMIN
.
get_users
():
KEYCLOAK_ADMIN
.
assign_realm_roles
(
user
[
"id"
],
""
,
roles
)
Event Timeline
anlambert
created this paste.
Apr 28 2021, 4:25 PM
2021-04-28 16:25:46 (UTC+2)
Log In to Comment