Skip to content

Use Authorization Code flow with PKCE in Keycloak OIDC federation #293

Closed

Description

@reqa

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
  • All acceptance criteria are met
  • Changes have been reviewed
  • CI tests have run successfully
  • Documentation has been updated
  • Release Notes have been updated

Activity

  1. added
    IAM
    on Mar 14, 2023
  2. added this to the R4 (v5.0.0) milestone on Mar 14, 2023
  3. moved this from Backlog to Doing in Sovereign Cloud Stackon Mar 15, 2023
  4. modified the milestones: R4 (v5.0.0), R5 (v6.0.0) on Mar 15, 2023
  5. fkr commented on Mar 15, 2023

    @fkr
    Member

    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.

  6. matfechner commented on Mar 15, 2023

    @matfechner

    This seems to be an Upstream Issue, we should bring this disscussion to the PTG

  7. fkr commented on Mar 17, 2023

    @fkr
    Member

    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?

  8. 4 remaining items

  9. berendt commented on Mar 20, 2023

    @berendt

    @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.

  10. reqa commented on Mar 20, 2023

    @reqa
    Author

    We can customize the defaults of Kolla via osism/ansible-defaults as we need them. We do not need to adapt this globally for the whole upstream.

    Add the parameter with the value you need + short explanation (reference to an issue is enough).

    https://github.com/osism/ansible-defaults/blob/main/all/099-kolla.yml

    Ok, as you merged https://github.com/osism/testbed/pull/1549/files already, where @JuanPTM put the adjustment into osism/testbed/environments/kolla/configuration.yml I guess not additional change to osism/ansible-defaults/blob/main/all/099-kolla.yml is required.

  11. reqa commented on Mar 20, 2023

    @reqa
    Author

    Just to clarify:

    • There are different "flavors" of the implicit grant, depending on the configuration of the response_type.
    • Why you should stop using the OAuth implicit grant talks about response_type token.
    • 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.
    • The section on implicit grant in the current draft of the OAuth 2.0 Security Best Current Practice primarily refers to token, not id_token.
    • 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.
    • In contrast, at the time of writing, the OpenID Connect Implicit Client Implementer's Guide 1.0 - draft 25 doesn't mention any security notice.
    • 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.
  12. mffap commented on Apr 12, 2023

    @mffap

    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.

  13. garloff commented on May 17, 2023

    @garloff
    Member

    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.)

  14. reqa commented on May 22, 2023

    @reqa
    Author
  15. moved this from Doing to Blocked / On hold in Sovereign Cloud Stackon Jun 21, 2023
  16. reqa commented on Aug 15, 2023

    @reqa
    Author

    My patch to support PKCE with Device Authorization Grant in OpenStack has been merged upstream.

  17. reqa commented on Aug 15, 2023

    @reqa
    Author

    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?

  18. garloff commented on Aug 23, 2023

    @garloff
    Member

    Update from 2023-08-23:

    • We need the code change that was accepted for upstream master (will be in bobcat). Possibly backported by upstream or by OSISM?
    • We need a config change for OSISM testbed and cfg-* repositories.
  19. reqa commented on Sep 11, 2023

    @reqa
    Author

    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.

    1. 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.

    Accordingly, the document linked above by @mffap

    the OAuth 2.1 standard will remove Implicit grant completely.

    explicitly says about OAuth 2.1:

    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.

    1. 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.
    
  20. garloff commented on Oct 25, 2023

    @garloff
    Member

    Done.

  21. moved this from Blocked / On hold to Done in Sovereign Cloud Stackon Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

IAM

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions