Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
keycloak-oeb-credentials-importer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
INB
ELIXIR
OpenEBench
openebench-keycloak
keycloak-oeb-credentials-importer
Commits
56e43279
Commit
56e43279
authored
Nov 06, 2020
by
redmitry@list.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use regular user instead of the KC 'admin'.
parent
abbdb6ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
keycloak-importer.py
keycloak-importer.py
+15
-9
No files found.
keycloak-importer.py
View file @
56e43279
...
...
@@ -6,18 +6,24 @@ import urllib.request
import
urllib.parse
OPENEBENCH_URL
=
"https://dev-openebench.bsc.es/api/scientific/access"
KEYCLOAK_TOKEN_ENDPOINT
=
"https://inb.bsc.es/auth/realms/
master
/protocol/openid-connect/token"
KEYCLOAK_TOKEN_ENDPOINT
=
"https://inb.bsc.es/auth/realms/
openebench
/protocol/openid-connect/token"
KEYCLOAK_OPENEBENCH_REALM
=
"https://inb.bsc.es/auth/admin/realms/openebench/"
def
main
():
if
(
len
(
sys
.
argv
)
>
1
):
password
=
sys
.
argv
[
1
]
username
=
sys
.
argv
[
1
]
else
:
print
(
'username:'
,
end
=
' '
)
username
=
str
(
input
())
if
(
len
(
sys
.
argv
)
>
2
):
password
=
sys
.
argv
[
2
]
else
:
print
(
'password:'
,
end
=
' '
)
password
=
str
(
input
())
token
=
getAdminToken
(
'admin'
,
password
)
token
=
getAdminToken
(
username
,
password
)
headers
=
{
'Authorization'
:
'Bearer '
+
token
}
updateCommunities
(
headers
)
...
...
@@ -35,7 +41,7 @@ def updateCommunities(headers):
# update existing communities
for
group
in
groups
[:]:
attributes
=
group
[
'attributes'
]
roles
=
attributes
.
get
(
'roles'
)
roles
=
attributes
.
get
(
'
oeb:
roles'
)
if
(
roles
!=
None
):
for
role
in
roles
:
if
(
role
.
startswith
(
'owner:'
)):
...
...
@@ -52,7 +58,7 @@ def updateCommunities(headers):
group
=
{}
group
[
'name'
]
=
community
[
'name'
]
#group['attributes'] = {'community_id' : [community['_id']], 'acronym' : [community['acronym']]}
group
[
'attributes'
]
=
{
'roles'
:
[
'owner:'
+
community
[
'_id'
]],
'acronym'
:
[
community
[
'acronym'
]]}
group
[
'attributes'
]
=
{
'
oeb:
roles'
:
[
'owner:'
+
community
[
'_id'
]],
'acronym'
:
[
community
[
'acronym'
]]}
addCommunityGroup
(
root
,
group
,
headers
)
#remove old communities
...
...
@@ -77,7 +83,7 @@ def updatePrivileges(headers):
if
(
email
==
user
[
'email'
]):
for
privilege
in
privileges
:
if
(
privilege
[
'_id'
]
==
contact
[
'_id'
]):
roles
=
privilege
.
get
(
'roles'
)
roles
=
privilege
.
get
(
'
oeb:
roles'
)
if
(
roles
!=
None
):
for
role
in
roles
:
community_id
=
role
.
get
(
'community_id'
)
...
...
@@ -96,7 +102,7 @@ def addContactToCommunity(groups, user, community_id, headers):
for
group
in
groups
:
attributes
=
group
[
'attributes'
]
roles
=
attributes
.
get
(
'roles'
)
roles
=
attributes
.
get
(
'
oeb:
roles'
)
if
(
roles
!=
None
):
for
role
in
roles
:
if
(
role
.
startswith
(
'owner:'
)
and
community_id
==
role
[
6
:]):
...
...
@@ -109,10 +115,10 @@ def addContactToChallenge(user, role, challenge_id, headers):
r
=
role
+
':'
+
challenge_id
attributes
=
user
[
'attributes'
]
rz
=
attributes
.
get
(
'roles'
)
rz
=
attributes
.
get
(
'
oeb:
roles'
)
if
(
rz
==
None
):
attributes
[
'roles'
]
=
[
r
]
attributes
[
'
oeb:
roles'
]
=
[
r
]
updateKeycloakUser
(
user
,
headers
)
elif
(
not
r
in
rz
):
rz
.
append
(
r
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment