forked from zjx-immersion/api-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjwt_auth.sh
More file actions
executable file
·42 lines (25 loc) · 1.57 KB
/
jwt_auth.sh
File metadata and controls
executable file
·42 lines (25 loc) · 1.57 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
#!/bin/bash
# Need to Install jq to extract json
host="localhost:8082"
#host="10.202.128.167:8080"
echo -e "\n\n----------------\n"
echo "Try to get api version"
curl -s http://$host/api/version
echo -e "\n\n----------------\n"
echo "Try to login"
curl -s -i -H "Content-Type: application/json" -XPOST http://$host/api/login -d '{"username":"admin","password":"admin"}'
#curl -s -H "Authorization: {AboveAuthorizationID}" -XGET http://$host/api/secure/product/123/123
echo -e "\n\n----------------\n"
echo "Try to refresh"
bear="Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiJiMDBmZGYzYi1mZWVjLTQyNWMtODY1ZS02ZTE0ZGRjMDI0NWUiLCJzdWIiOiJhZG1pbiIsImV4cCI6MTUwMzUwMjAxNH0.EpB-RPKz_XEeTGICCag9aUMwlLkGgFAh8bRk4s4WeStKMEkbAJJUH7jxNFjOU3aSrak4IzAODs08JosiT5FKNA"
curl -s -i -H "$bear" -XPOST http://$host/api/secure/token/refresh
echo -e "\n\n----------------\n"
echo "Try to update password by wrong oldPassword"
curl -s -i -H "Content-type: application/json" -H "$bear" -XPUT http://$host/api/secure/user/password -d '{"oldPassword": "hello", "newPassword": "hello"}'
echo -e "\n\n----------------\n"
echo "Try to update password by correct password"
curl -s -i -H "Content-type: application/json" -H "$bear" -XPUT http://$host/api/secure/user/password -d '{"oldPassword": "admin", "newPassword": "password"}'
echo -e "\n\n----------------\n"
echo "Try to login with new password"
curl -s -i -H "Content-Type: application/json" -XPOST http://$host/api/login -d '{"username":"admin","password":"password"}'
curl -s -i -H "Authorization: Bearer ff" -XGET http://$host/api/secure/qrcode