-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathllng
executable file
·195 lines (182 loc) · 2.88 KB
/
llng
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/sh
#
#
# Authors : P Vilarem <[email protected]>
# X Guimard <[email protected]>
#
# Licence : GPL V3 https://www.gnu.org/licenses/gpl-3.0.en.html
VERSION='0.1.0'
SIMPLEOIDCCLIENTLIBDIR=${SIMPLEOIDCCLIENTLIBDIR:-$(dirname $(test -L "$0" && readlink "$0" || echo "$0"))}
if [ ! -f $SIMPLEOIDCCLIENTLIBDIR/llng-lib.sh ] ; then
SIMPLEOIDCCLIENTLIBDIR=$(dirname $0)/"$SIMPLEOIDCCLIENTLIBDIR"
fi
. $SIMPLEOIDCCLIENTLIBDIR/llng-lib.sh
check_install
usage () {
echo 'LemonLDAP::NG OpenID-Connect client'
echo
echo "$0 <options> <command>"
echo
echo 'See https://github.com/linagora/simple-oidc-client/tree/master/sh#readme'
}
# 1. GET PARAMETERS
while true; do
case "$1" in
'-v'|'--version')
echo $VERSION
exit
;;
'-h'|'--help')
usage
exit
;;
'-c'|'--cookie-jar')
COOKIEJAR="$2"
shift 2
;;
'-u'|'--login'|'--user')
LLNG_LOGIN="$2"
shift 2
;;
'-P'|'--prompt')
PROMPT=yes
shift
;;
'-p'|'--password'|'--llng-password')
LLNG_PASSWORD="$2"
shift 2
;;
'-h'|'--llng-server')
LLNG_SERVER="$2"
shift 2
;;
'-H'|'--llng-url')
LLNG_URL="$2"
shift 2
;;
'-k'|'--pkce')
PKCE=1
shift
;;
'-i'|'--client-id')
CLIENT_ID="$2"
shift 2
;;
'-s'|'--client-secret')
CLIENT_SECRET="$2"
shift 2
;;
'-r'|'--redirect-uri')
REDIRECT_URI="$2"
shift 2
;;
'--debug')
DEBUG=1
shift
;;
'-o'|'--scope')
SCOPE="$2"
shift 2
;;
'--matrix-server')
MATRIX_SERVER="$2"
shift 2
;;
'--matrix-user')
MATRIX_USER="$2"
shift 2
;;
'--curl-opts')
CURLOPTS="$2"
shift 2
;;
'--access-token')
LLNG_ACCESS_TOKEN="$2"
shift 2
;;
'--choice')
LLNG_CHOICE="$2"
shift 2
;;
'--')
shift
break
;;
*)
if test "$1" != "${1#-}"; then
echo "Unknown option $1" >&2
usage
exit 1
fi
break
;;
?)
echo Aborting >&2
exit 1
;;
esac
done
if test "$LLNG_SERVER" = "" -a "$LLNG_URL" = ""
then
LLNG_SERVER=$(askString Server)
fi
if test "$LLNG_URL" = ""
then
LLNG_URL=$(build_llng_url)
fi
COMMAND="$1"
if test "$COMMAND" != ""; then
shift
fi
case "$COMMAND" in
whoami)
whoami
;;
languages)
getLanguages
;;
llng_cookie)
getLlngId
;;
oidc_metadata)
getOidcMetadata
;;
oidc_endpoints)
getOidcEndpoints
env|grep _ENDPOINT
;;
oidc_tokens)
getOidcTokens
;;
access_token)
getAccessToken
;;
id_token)
getIdToken
;;
refresh_token)
getRefreshToken
;;
user_info)
getUserInfo
;;
introspection)
getIntrospection "$@"
;;
matrix_token)
getMatrixToken "$@"
;;
matrix_federation_token)
getMatrixFederationToken "$@"
;;
matrix_token_exchange)
getAccessTokenFromMatrixToken "$@"
;;
logout)
logout
;;
*)
echo "BAD COMMAND $COMMAND" >&2
echo "Accepted commands: whoami, access_token, id_token, refresh_token" >&2
exit 1
esac