You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use Authorization Code flow with PKCE in Keycloak OIDC federation #293
As a user of SCS, I want Keystone OIDC federation to use "Authorization Code flow with PKCE" instead of "Implicit Grant" so that I follow security best practice for OpenID Connect.
Definition of Ready:
User Story is small enough to be finished within one sprint
User Story is clear and understood by the whole team
Acceptance criteria are defined
Acceptance criteria are clear and understood by the whole team
Definition of Done:
Put OIDCPKCEMethod plain into the wsgi-keystone.conf. Maybe there are also even better settings
We should also disable the Implicit Flow in the keystone client config in Keycloak
We set this to R4, it is not really likely we will make this for R4, since this is change in OSISM and OSISM has been frozen for their 5.0.0 release (which is the base for R4). TBD.
Not really sure, wether I'm the only one but maybe it can be elaborated what exactly should be addressed where upstream?
Defaults coming from kolla-ansible? Or defaults coming from keystone?
@JuanPTM This changes the behavior in the testbed, yes. But not the general behavior of OSISM. For that, the changes have to be made in osism/ansible-defaults.
Fortunately we are not talking here about that most problematic flow, where the access token can be leaked. Instead the upstream recommended wsgi-keycloak.conf configuration uses id_token.
According to OpenID-Connect core specification, the response parameters are returned in the Redirection URI fragment value, i.e. by appending #id_token= to the redirect URI.
From this info and following e.g. this report I think that the id_token can be leaked in our case. I guess the implications are less severe than with token included in the response_type.
The use case for implicit grant are Web clients (SPA) which can cannot keep a client secret.
I don't think that Keystone SSO Federation is limited to using implicit grant, so we should not use it if we can avoid it.
The successful WebSSO (horizon) test with Authorization Code Flow with PKCE with Zitadel (and later reproduced with Keycloak) shows that we have at least one alternative. There may be even better ones.
Switching over from implicit grant to PKCE, which needs additional enablement in keystone.
Followup patch (to the work from #261) needed there. Including Docs.
Switch in testbed already performed.
(Workaround in place for now until keystone patch exists and is merged. Workaround has questionable security properties -- access token is trusted unconditionally, may or may not be by design.)
FYI: Just a technical clarification: Recently I stumbled upon this again, and found that this has both, a security aspect on the one hand and an interoperability aspect on the other hand.
Security:
The kolla-ansible upstream uses keystone_federation_oidc_response_type: "id_token" which, according to the OpenID Connect Core 1.0 spec is also a type of Implicit Flow, but still different from the Implicit Grant defined by response_type: token, which issues an access_token directly from the authorization endpoint (rather than an id_token). -- So, there is a difference here between OAuth 2.0 Implicit Grant (which is deprecated) and the Implicit Flow mentioned in the OpenID Connect spec.
Removal of response_type=token does not have an effect on other extension response types
returning other artifacts from the authorization endpoint, for example, response_type=id_token
defined by [[OpenID](https://openid.net/specs/openid-connect-core-1_0.html)].
So these are different things. Yet, as already elaborated in my clarification note above, I think it's good to use the authorization code instead of implicit flows.
Interoperability
But there is also an interoperability aspect to it with regards to the choice of IdP. As this overview by authlete points out:
Be careful when you select an authorization server because there exist implementations
which support response_type=code only but claim they support OpenID Connect.
Activity
fkr commentedon Mar 15, 2023
We set this to R4, it is not really likely we will make this for R4, since this is change in OSISM and OSISM has been frozen for their 5.0.0 release (which is the base for R4). TBD.
matfechner commentedon Mar 15, 2023
This seems to be an Upstream Issue, we should bring this disscussion to the PTG
fkr commentedon Mar 17, 2023
Not really sure, wether I'm the only one but maybe it can be elaborated what exactly should be addressed where upstream?
Defaults coming from kolla-ansible? Or defaults coming from keystone?
4 remaining items
berendt commentedon Mar 20, 2023
@JuanPTM This changes the behavior in the testbed, yes. But not the general behavior of OSISM. For that, the changes have to be made in osism/ansible-defaults.
reqa commentedon Mar 20, 2023
Ok, as you merged https://github.com/osism/testbed/pull/1549/files already, where @JuanPTM put the adjustment into
osism/testbed/environments/kolla/configuration.ymlI guess not additional change toosism/ansible-defaults/blob/main/all/099-kolla.ymlis required.reqa commentedon Mar 20, 2023
Just to clarify:
response_type.token.wsgi-keycloak.confconfiguration usesid_token.response parameters are returned in the Redirection URI fragment value, i.e. by appending#id_token=to the redirect URI.token, notid_token.id_tokencan be leaked in our case. I guess the implications are less severe than withtokenincluded in theresponse_type.Modify ansible default to use authorization code. (#118)
mffap commentedon Apr 12, 2023
Maybe as additional consideration: Besides the best practices recommendation for OAuth 2.0 to drop Implicit Grant, the OAuth 2.1 standard will remove Implicit grant completely.
garloff commentedon May 17, 2023
Switching over from implicit grant to PKCE, which needs additional enablement in keystone.
Followup patch (to the work from #261) needed there. Including Docs.
Switch in testbed already performed.
(Workaround in place for now until keystone patch exists and is merged. Workaround has questionable security properties -- access token is trusted unconditionally, may or may not be by design.)
reqa commentedon May 22, 2023
I've submitted https://review.opendev.org/c/openstack/keystoneauth/+/883852 for upstream review.
reqa commentedon Aug 15, 2023
My patch to support PKCE with Device Authorization Grant in OpenStack has been merged upstream.
reqa commentedon Aug 15, 2023
Not sure if the changes that have been applied to the testbed for this also need to be reflected in https://github.com/osism/cfg-cookiecutter . Maybe @matfechner knows?
garloff commentedon Aug 23, 2023
Update from 2023-08-23:
reqa commentedon Sep 11, 2023
FYI: Just a technical clarification: Recently I stumbled upon this again, and found that this has both, a security aspect on the one hand and an interoperability aspect on the other hand.
The kolla-ansible upstream uses
keystone_federation_oidc_response_type: "id_token"which, according to the OpenID Connect Core 1.0 spec is also a type ofImplicit Flow, but still different from theImplicit Grantdefined byresponse_type: token, which issues anaccess_tokendirectly from the authorization endpoint (rather than anid_token). -- So, there is a difference here between OAuth 2.0Implicit Grant(which is deprecated) and theImplicit Flowmentioned in the OpenID Connect spec.Accordingly, the document linked above by @mffap
explicitly says about OAuth 2.1:
So these are different things. Yet, as already elaborated in my clarification note above, I think it's good to use the authorization code instead of implicit flows.
But there is also an interoperability aspect to it with regards to the choice of IdP. As this overview by authlete points out:
garloff commentedon Oct 25, 2023
Done.