-
Notifications
You must be signed in to change notification settings - Fork 0
/
oc-addrole
executable file
·42 lines (29 loc) · 962 Bytes
/
oc-addrole
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
dirName=`dirname $0`
progName=`basename $0`
# Usage
# =====
function usage() {
echo "NOM"
echo " $progName"
echo "SYNOPSIS"
echo " $progName client_login client_password userSub roleName"
echo "DESCRIPTION"
echo " Requests an access token on the authentication SERVEUR using client credentials,"
echo " then gives a user (using his/her related userSub) the role roleName"
echo " role example : 'manager-dev:dictionary-user'"
}
# Command line
# ============
if [[ "$1" == "--help" || "$1" == "-h" || $# -ne 4 ]]; then
usage
exit 1
fi
# Execution
# =========
token=`${dirName}/oc-token $1 $2`
if [ "$token" == "null" ]; then
echo "ERREUR invalid token. Please check client credentials."
exit 1
fi
curl -i -X POST --data "{ \"role\": \"$4\" }" --header 'Content-type: application/json' --header "Authorization: Bearer $token" "https://accounts.organicity.eu/permissions/users/$3/roles"