Created
March 11, 2024 10:55
-
-
Save likid0/eb8a05b130a5c0d00805bf08cfdb806f to your computer and use it in GitHub Desktop.
Ugly Example, just for testing and inspecting a JWT token using curl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cat check_token.sh | |
USERNAME=$1 | |
PASSWORD=$2 | |
KC_CLIENT="ceph" | |
KC_CLIENT_SECRET="XXXXXSECRETXXXX" | |
KC_ACCESS_TOKEN="$(./get_web_token.sh $USERNAME $PASSWORD | jq -r '.access_token')" | |
KC_SERVER="https://keycloak-sso.apps.example.local" | |
KC_CONTEXT="auth" | |
KC_REALM="ceph" | |
curl -k -s -q \ | |
-X POST \ | |
-u "$KC_CLIENT:$KC_CLIENT_SECRET" \ | |
-d "token=$KC_ACCESS_TOKEN" \ | |
"$KC_SERVER/$KC_CONTEXT/realms/$KC_REALM/protocol/openid-connect/token/introspect" | jq . | |
# cat get_web_token.sh | |
curl -k -s -q -L -X POST "https://keycloak-sso.apps.example.local/auth/realms/ceph/protocol/openid-connect/token" \ | |
-H 'Content-Type: application/x-www-form-urlencoded' \ | |
--data-urlencode 'client_id=ceph' \ | |
--data-urlencode 'grant_type=password' \ | |
--data-urlencode 'client_secret=XXXsssXXXsssXXX' \ | |
--data-urlencode 'scope=openid' \ | |
--data-urlencode "username=$1" \ | |
--data-urlencode "password=$2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment