forked from willwiggins/mac_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrontapp-deprovision
49 lines (42 loc) · 1.49 KB
/
frontapp-deprovision
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
42
43
44
45
46
47
48
49
#!/bin/sh
# This script is used to deprovision a user in Front App by using the Front SCIM APIs
# API Docs: https://documenter.getpostman.com/view/1614368/RVfsHZ6o#eeca7798-dde8-3621-b55e-d2ff1e2b667b
# Pass username while running the script, i.e. bash script.sh username
user=$1
# Sets Authentication token to variable
TOKEN=<insert token here>
# Gets list of users
USERS=$(curl --request GET \
--url 'https://scim.frontapp.com/v2/Users' \
--header 'Accept: application/scim+json' \
--header "Authorization: Bearer $TOKEN" \
)
# Gets String that contains users id
USER_ID_TEMP=$(echo $USERS | egrep -o '.{0,170}"'${user}'@salesloft.com"')
# Gets User ID and Sets to Variable
USER_ID=$(echo "$USER_ID_TEMP" \
| grep -o '"id": *"[^"]*"' \
| grep -o '"[^"]*"$' \
| tr -d '"'
)
# Just for troubleshooting to verify variable contents
ECHO "TEMP USER ID IS" $USER_ID_TEMP
ECHO "USER ID IS" $USER_ID
echo "Listing User"
curl --request GET \
--url "https://scim.frontapp.com/v2/Users/$USER_ID" \
--header 'Accept: application/scim+json' \
--header "Authorization: Bearer $TOKEN"
echo "Revoking Access"
curl --request PUT \
--url "https://scim.frontapp.com/v2/Users/$USER_ID" \
--header 'Accept: application/scim+json' \
--header "Authorization: Bearer $TOKEN" \
--header 'Content-Type: application/scim+json' \
--data '{
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:User"
],
"id": '\"$USER_ID\"',
"active": false
}'