Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-operations
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal
paas
drupal-operations
Merge requests
!16
Modify authz resources
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Modify authz resources
modify-authz-resources
into
master
Overview
17
Commits
8
Pipelines
7
Changes
3
Merged
Francisco Borges Aurindo Barros
requested to merge
modify-authz-resources
into
master
3 years ago
Overview
17
Commits
8
Pipelines
7
Changes
3
Expand
Part of
https://gitlab.cern.ch/webservices/webframeworks-planning/-/issues/735
0
0
Merge request reports
Compare
master
version 6
d7496266
3 years ago
version 5
69dad6a3
3 years ago
version 4
190d507e
3 years ago
version 3
131e7d3f
3 years ago
version 2
03c3e8ee
3 years ago
version 1
2e4ae939
3 years ago
master (base)
and
version 2
latest version
a478e654
8 commits,
3 years ago
version 6
d7496266
7 commits,
3 years ago
version 5
69dad6a3
6 commits,
3 years ago
version 4
190d507e
5 commits,
3 years ago
version 3
131e7d3f
4 commits,
3 years ago
version 2
03c3e8ee
3 commits,
3 years ago
version 1
2e4ae939
2 commits,
3 years ago
3 files
+
135
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
scripts/addGroupToDrupalAdmins.sh
0 → 100755
+
47
−
0
Options
#!/bin/bash
usage
()
{
echo
"Usage:
$0
[--group-name <GROUP> --project <PROJECT>]"
1>&2
;
exit
1
;
}
# Options
ARGS
=
$(
getopt
-o
'g:p:'
--long
'group-name:project:'
--
"
$@
"
)
||
exit
1
eval
"set --
$ARGS
"
while
true
;
do
case
"
$1
"
in
(
-g
|
--group-name
)
GROUP_NAME
=
"
$2
"
;
shift
2
;;
(
-p
|
--project
)
PROJECT
=
"
$2
"
;
shift
2
;;
(
--
)
shift
;
break
;;
(
*
)
usage
;;
esac
done
[[
-z
"
${
KUBECONFIG
}
"
]]
&&
echo
"No cluster access!"
&&
usage
[[
-z
"
${
GROUP_NAME
}
"
]]
&&
usage
[[
-z
"
${
PROJECT
}
"
]]
&&
usage
export
AUTHZAPI_URL
=
$(
oc get deploy/authz-operator
-n
openshift-cern-authz-operator
-o
json | jq
-r
'.spec.template.spec.containers[0].env[] | select(.name == "AUTHZAPI_URL") | .value'
)
export
KC_ISSUER_URL
=
$(
oc get deploy/authz-operator
-n
openshift-cern-authz-operator
-o
json | jq
-r
'.spec.template.spec.containers[0].env[] | select(.name == "KC_ISSUER_URL") | .value'
)
export
KC_CLIENT_ID
=
$(
oc get secret
-n
openshift-cern-authz-operator operator-keycloak-credentials
-o
json | jq
-r
'.data.CLIENT_ID'
|
base64
-d
)
export
KC_CLIENT_SECRET
=
$(
oc get secret
-n
openshift-cern-authz-operator operator-keycloak-credentials
-o
json | jq
-r
'.data.CLIENT_SECRET'
|
base64
-d
)
export
BEARER_TOKEN
=
$(
curl
-m
45
--silent
--fail
-XPOST
${
KC_ISSUER_URL
}
/api-access/token
-d
"grant_type=client_credentials&client_id=
${
KC_CLIENT_ID
}
&client_secret=
${
KC_CLIENT_SECRET
}
&audience=authorization-service-api"
| jq
-r
'.access_token'
)
export
AUTHZAPI_VERSION
=
"api/v1.0"
APPLICATION_ID
=
$(
oc get applicationregistration
-n
${
PROJECT
}
-o
json | jq
-r
'.items[0].status.id'
)
# Retrieve list of Roles
ROLE_LIST
=
$(
curl
--silent
-X
GET
"
${
AUTHZAPI_URL
}
/
${
AUTHZAPI_VERSION
}
/Application/
${
APPLICATION_ID
}
/roles"
-H
"accept: text/plain"
-H
"Authorization: Bearer
${
BEARER_TOKEN
}
"
)
# Extract Administrator ID from roles
ROLE_ID
=
$(
echo
$ROLE_LIST
| jq
-r
'.data[] | select(.name=="administrator") | .id'
)
GROUP_EXISTS
=
$(
curl
--silent
-X
GET
"
${
AUTHZAPI_URL
}
/
${
AUTHZAPI_VERSION
}
/Group/
${
GROUP_NAME
}
"
-H
"accept: text/plain"
-H
"Authorization: Bearer
${
BEARER_TOKEN
}
"
-d
""
-o
/dev/null
-w
"%{http_code}"
)
if
[[
$GROUP_EXISTS
!=
"200"
]]
;
then
echo
"Error trying to find group in API, error code:
${
GROUP_EXISTS
}
"
exit
1
fi
SUCCESS
=
$(
curl
--silent
-X
POST
"https://authorization-service-api.web.cern.ch/api/v1.0/Application/
${
APPLICATION_ID
}
/roles/
${
ROLE_ID
}
/groups/
${
GROUP_NAME
}
"
-H
"accept: text/plain"
-H
"Authorization: Bearer
${
BEARER_TOKEN
}
"
-d
""
-o
/dev/null
-w
"%{http_code}"
)
if
[[
$SUCCESS
!=
"200"
]]
;
then
echo
"Error binding group to admin role, error code:
${
SUCCESS
}
"
exit
1
fi
echo
"Successfully binded
${
GROUP_NAME
}
to applicationID
${
APPLICATION_ID
}
"
Loading