-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinvoke-authenticated.sh
executable file
·18 lines (12 loc) · 1.5 KB
/
invoke-authenticated.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
export DIRECT_GRANT_RESPONSE=$(curl -i --request POST http://localhost:8080/auth/realms/master/protocol/openid-connect/token --header "Accept: application/json" --header "Content-Type: application/x-www-form-urlencoded" --data "grant_type=password&username=admin&password=admin&client_id=admin-cli")
echo -e "\n\nSENT RESOURCE-OWNER-PASSWORD-CREDENTIALS-REQUEST. OUTPUT IS:\n\n";
echo $DIRECT_GRANT_RESPONSE;
export ACCESS_TOKEN=$(echo $DIRECT_GRANT_RESPONSE | grep "access_token" | sed 's/.*\"access_token\":\"\([^\"]*\)\".*/\1/g');
echo -e "\n\nACCESS TOKEN IS \"$ACCESS_TOKEN\"";
echo -e "\n\nSENDING UN-AUTHENTICATED REQUEST. THIS SHOULD FAIL WITH 401: ";
curl -i --request POST http://localhost:8080/auth/realms/master/skss/sp-auth --data "{ \"name\": \"scim2 sp\", \"endPoint\": \"http://localhost:9090/scim2\", \"username\": \"scim2\", \"password\": \"scim2\" }" --header "Content-type: application/json"
echo -e "\n\nSENDING AUTHENTICATED REQUEST. THIS SHOULD SUCCESSFULLY CREATE COMPANY AND SUCCESS WITH 201: ";
curl -i --request POST http://localhost:8080/auth/realms/master/skss/sp-auth --data "{ \"name\": \"scim2 sp\", \"endPoint\": \"http://localhost:9090/scim2\", \"username\": \"scim2\", \"password\": \"scim2\" }" --header "Content-type: application/json" --header "Authorization: Bearer $ACCESS_TOKEN";
echo -e "\n\nSEARCH SERVICE PROVIDERS: ";
curl -i --request GET http://localhost:8080/auth/realms/master/skss/sp-auth --header "Accept: application/json" --header "Authorization: Bearer $ACCESS_TOKEN";