mirror of https://github.com/jacekkow/keycloak-protocol-cas

Updater Bot
2019-01-16 06c169131e43a23d338475a016dcd8ab8964db15
commit | author | age
33112b 1 #!/bin/bash
MP 2 set -e
3
4 action_pattern='action="([^"]+)"'
5 ticket_pattern='Location: .*\?ticket=(ST-[-A-Za-z0-9_.=]+)'
6
7 get_ticket() {
8     login_response=$(curl --fail --silent -c /tmp/cookies http://localhost:8080/auth/realms/master/protocol/cas/login?service=http://localhost)
9     if [[ !($login_response =~ $action_pattern) ]] ; then
10         echo "Could not parse login form in response"
11         echo $login_response
12         exit 1
13     fi
14
6638b8 15     login_url=${BASH_REMATCH[1]//&/&}
33112b 16     redirect_response=$(curl --fail --silent -D - -b /tmp/cookies --data 'username=admin&password=admin' "$login_url")
MP 17     if [[ !($redirect_response =~ $ticket_pattern) ]] ; then
18         echo "No service ticket found in response"
19         echo $redirect_response
20         exit 1
21     fi
22
23     ticket=${BASH_REMATCH[1]}
24     echo $ticket
25 }
26
27 get_ticket
28 curl --fail --silent "http://localhost:8080/auth/realms/master/protocol/cas/validate?service=http://localhost&ticket=$ticket"
29 echo
30
31 get_ticket
32 curl --fail --silent "http://localhost:8080/auth/realms/master/protocol/cas/serviceValidate?service=http://localhost&format=XML&ticket=$ticket"
33 echo
34
35 get_ticket
36 curl --fail --silent "http://localhost:8080/auth/realms/master/protocol/cas/serviceValidate?service=http://localhost&format=JSON&ticket=$ticket"
37 echo
38
39 get_ticket
40 curl --fail --silent "http://localhost:8080/auth/realms/master/protocol/cas/p3/serviceValidate?service=http://localhost&format=JSON&ticket=$ticket"
41 echo