-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathauthn
More file actions
executable file
·58 lines (46 loc) · 1.27 KB
/
authn
File metadata and controls
executable file
·58 lines (46 loc) · 1.27 KB
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
50
51
52
53
54
55
56
57
58
#!/usr/bin/bash
if [[ -z $okapi_url ]] && [[ ! -f okapi.url ]];then
echo -n "Okapi URL: "
read -r okapi_url
echo -n "$okapi_url" > okapi.url
else
okapi_url=$(cat okapi.url)
fi
if [[ -z $tenant ]] && [[ ! -f tenant ]];then
echo -n "tenant: "
read -r tenant
echo -n "$tenant" > tenant
else
tenant=$(cat tenant)
fi
if [[ -z $auth_tenant ]] && [[ ! -f auth.tenant ]];then
echo -n "Auth tenant: "
read -r auth_tenant
echo -n "$auth_tenant" > auth.tenant
else
tenant=$(cat tenant)
fi
if [[ ${auth_tenant} == "" ]];then auth_tenant=${tenant};fi
if [[ ! -f okapi-login.json ]];then
echo -n "Username: "
read -r username
echo -n "Password: "
read -r pwd
IFS='' read -r -d '' okapi_login << EndOfAuth
{
"tenant": "${tenant}",
"username": "${username}",
"password": "${pwd}"
}
EndOfAuth
echo "${okapi_login}" > okapi-login.json
else
okapi_login=$(cat okapi-login.json)
fi
okapi_token=$(curl -c - -s -X POST -H "Content-type: application/json" -H "X-Okapi-Tenant: ${tenant}" -d "${okapi_login}" "${okapi_url}/authn/login-with-expiry" |grep folioAccessToken| cut -f7)
if [[ ! ${okapi_token} =~ [a-z] ]];then
echo "okapi token not acquired"
exit
else
echo -n ${okapi_token} > okapi.token
fi