-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjwt.sh
More file actions
23 lines (15 loc) · 710 Bytes
/
jwt.sh
File metadata and controls
23 lines (15 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
APPS="live"
jwt_token() {
header='{"alg":"HS256","typ":"JWT"}'
payload='{"iat": 1516239022}'
header_base64=$(echo -n "$header" | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n')
payload_base64=$(echo -n "$payload" | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n')
data="$header_base64.$payload_base64"
secret=`cat /usr/local/antmedia/webapps/$APPS/WEB-INF/red5-web.properties |grep "jwtSecretKey" | awk -F "=" '{print $2}'`
signature=$(echo -n "$data" | openssl dgst -sha256 -hmac "$secret" -binary | openssl base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n')
jwt="$data.$signature"
echo "$jwt"
}
JWT_TOKEN=$(jwt_token)
echo $JWT_TOKEN