OpenShift token retrieval from Keycloak may return a stale token #19720
Labels
area/che-server
kind/bug
Outline of a bug - must adhere to the bug report template.
severity/P1
Has a major impact to usage or development of the system.
Describe the bug
When using an access token obtained from Keycloak using the token exchange algorithm using a valid openshift token, che server is then unable to perform authenticated request to OpenShift because the token it is able to obtain from keycloak is not the one used to obtain the token.
Che version
latest
Steps to reproduce
CLUSTER_DOMAIN
be the root domain of an OpenShift 4 cluster.oc
with some administrative account.oc login -u A --server=https://api.$CLUSTER_DOMAIN:6443
oc whoami -t
$KC_TOKEN
Keycloak token, e.g.:Expected behavior
The access token was obtained using a valid OpenShift token, so it should succeed. But the operation fails with unauthorized error.
I would expect that the OpenShift token I used to generated a Keycloak token would be used when converting the Keycloak token back to OpenShift token during the calls made by the che server.
This is most probably because Che server doesn't use the token exchange algorithm to get the OpenShift token (see below). Not that we need to make sure this also works on OpenShift 3.
Runtime
OpenShift 4.6
Installation method
chectl server:deploy -p openshift -a operator
Eclipse Che Logs
N/A
Additional context
It looks like when using token exchange for getting the Keycloak token, the OpenShift token used for that is not persisted in all places inside Keycloak. Che server does not use token exchange for getting the token. Instead, it uses an equivalent of this call:
But this returns the OpenShift token last used in the UI login.
When the token exchange algorithm is used for getting the OpenShift token from the Keycloak token (using the Keycloak token obtained from token exchange itself), the OpenShift token used for obtaining that Keycloak token is returned.
The text was updated successfully, but these errors were encountered: