token_type_hint가 requesting_party_token인 경우 Keycloak 내부 검사 엔드포인트가 비활성 상태로 반환됩니다.

token_type_hint가 requesting_party_token인 경우 Keycloak 내부 검사 엔드포인트가 비활성 상태로 반환됩니다.

Keycloak 3.4.3-Final을 사용하고 있습니다. keycloak 버전을 변경하는 것은 나에게 옵션이 아닙니다. 클라이언트와 사용자를 생성하고 사용자 ID/PW를 사용하여 JWT를 얻은 후 이 JWT를 검사해 보았습니다. token_type_hint=requesting_party_token을 지정하면 Keycloak은 JWT가 비활성 상태임을 반환합니다. token_type_hint를 생략하면 토큰이 활성화되었다는 결과가 나옵니다.

문제를 재현하는 방법은 다음과 같습니다.

# run keycloak using docker
docker run -d jboss/keycloak:3.4.3.Final

# create a client and user. keycloak config is https://gist.github.com/roengram/9beba13665592322d666a92110ac1ff9

# get a JWT using user ID/PW
curl -s -d \
  "client_id=${CLIENT_ID}" \
  -d "client_secret=${CLIENT_SECRET}" \
  -d "username=${USERID}" -d "password=${USERPW}" \
  -d "grant_type=password" \
  "${KEYCLOAK_ENDPOINT}/auth/realms/${REALM}/protocol/openid-connect/token"
{"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI2RUpvU0RnOEtBeHlKUHhjODM3UC1kMFlac1NUS2drU...

# introspect the token according to https://www.keycloak.org/docs/3.4/authorization_services/#obtaining-information-about-an-rpt
curl -X POST \
  -u ${CLIENT_ID}:${CLIENT_SECRET} \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d 'token_type_hint=requesting_party_token&token=${JWT}' \
  "${KEYCLOAK_ENDPOINT}/auth/realms/${REALM}/protocol/openid-connect/token/introspect"
{"active":false}

# if token_type_hint is omitted, active is returned
curl -X POST \
  -u ${CLIENT_ID}:${CLIENT_SECRET} \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d 'token=${JWT}' \
  "${KEYCLOAK_ENDPOINT}/auth/realms/${REALM}/protocol/openid-connect/token/introspect"
{"jti":"89eaa1b0-86bc-4ea2-8bf4-58dca2e3e794","exp":1560252718,"nbf":0,"iat":1560249118,"iss":"http://172.19.0.4:8080/auth/realms/master","aud":"testclient","sub":"843deccc-07f0-45b5-9965-653405a84bfe","typ":"Bearer","azp":"testclient","auth_time":0,"session_state":"eee130fc-00d8-4f0c-912d-d65de81982d0","preferred_username":"roen","acr":"1","allowed-origins":[],"realm_access":{"roles":["uma_authorization"]},"resource_access":{"account":{"roles":["manage-account","manage-account-links","view-profile"]}},"client_id":"testclient","username":"roen","active":true}

아마도 잘못된 token_type_hint를 사용하고 있는 것일까요? 에 따르면투기, token_type_hint는 서버에서 토큰 조회를 최적화하기 위해 선택적으로 사용되며 무시할 수 있습니다. keycloak에 제출한 토큰이 RPT가 아닌 것 같아서 keycloak이 단순히 비활성 상태로 반환됩니다.

관련 정보