Skip to content

OIDC implementation - #2960

Merged
ssddanbrown merged 25 commits into
masterfrom
oidc
Oct 16, 2021
Merged

ssddanbrown merged 25 commits into
masterfrom
oidc

Conversation

@ssddanbrown

@ssddanbrown ssddanbrown commented Oct 6, 2021

Copy link
Copy Markdown
Member

Continuation of #2169

TODO

  • Look to address PHP8+ compatibility. Either choose different libraries or assist the upgrade of upstream projects.
  • Add basic-level auto-discovery to handle key & endpoint fetching.
  • Update and ensure coverage of automated testing.
  • Test with multiple auth providers
    • Okta
    • Keycloak
    • Auth0
  • Sponsor phpseclib

References

For Docs

  • Mention default cache time of 15 mins for auto-discovery.
  • Advise that only RS256 id token signing is currently supported.

jasperweyne and others added 16 commits July 1, 2020 23:27
- Made oidc config more generic to not be overly reliant on the library
  based upon learnings from saml2 auth.
- Removed any settings that are redundant or not deemed required for
  initial implementation.
- Reduced some methods down where not needed.
- Renamed OpenID to OIDC
- Updated .env.example.complete to align with all options and their
  defaults

Related to #2169
- Removed uneeded custom refresh or logout actions for OIDC.
- Restructured how the services and guards are setup for external auth
  systems. SAML2 and OIDC now directly share a lot more logic.
- Renamed any OpenId references to OIDC or OpenIdConnect
- Removed non-required CSRF excemption for OIDC

Not tested, Come to roadblock due to lack of PHP8 support in upstream
dependancies. Certificate was deemed to be non-valid on every test
attempt due to changes in PHP8.
- Got basic signing support and structure checking done.
- Need to run through actual claim checking before providing details
  back to app.
- Validation of all key/token elements now in place.
- Signing key system updated to work with jwk-style array or with
  file:// path to pem key.
- To continue coverage and spec cases next.
@sg3s

sg3s commented Oct 13, 2021

Copy link
Copy Markdown

Some of your dependencies you added here have overlapping logic/functionalities, and you might be able to abstract some heavy lifting of handling keys and doing checks may be outsourced to other/better dependencies.

The library phpseclib/phpseclib seems to have some overlap with lcobucci/jwt (sub dependency of league/oauth2-client). I've personally not used phpseclib but am not / was not impressed by lcobucci/jwt (though the v4 is much better, but it took a while to release).

We've adopted the following which helped us get rid of more boilerplate key retrieval/matching logic and signature & claim checks. It might help to reduce logic here too. Especially the checking a token against a keyset url is powerful and supported algorithms is pretty useful.
https://web-token.spomky-labs.com/

Of course make your own judgement, I must admit I've not been able to go through all code in detail.

@ssddanbrown

Copy link
Copy Markdown
Member Author

Thanks for the input @sg3s. It may be that old diffs are showing or something, I've been slowly changing the implementation of that from the original PR hence there has been some overlapping dependencies. Should be cleaned-up as of last night though.

The library phpseclib/phpseclib seems to have some overlap with lcobucci/jwt (sub dependency of league/oauth2-client). I've personally not used phpseclib but am not / was not impressed by lcobucci/jwt (though the v4 is much better, but it took a while to release).

I don't see lcobucci/jwt as a sub-dependency of oauth2-client, It was a dependency of the steverhoades/oauth2-openid-connect-client library that was originally used though.

I had issues with library versions, or libraries having larger than desired dependency chains or questionable maintenance & testing coverage. When I got into things, the slice of JWT handing that we need to take into account of for OIDC seemed quite focused, with the spec being clear about validation required. Therefore I'm taking the approach of adding the OIDC & JWT layer myself with phpseclib doing heavy lifting for keys and league/oauth2-client doing heavy lifting for OAuth elements.

It's pretty much there now, Just fleshing out testing coverage. Basic auto-discovery is now possible, and key handling has been reworked to run via jwk or a key file as per the original PR.

@sg3s

sg3s commented Oct 13, 2021

Copy link
Copy Markdown

My bad, I might have assumed where lcobucci/jwt came from and I did go through things by commit. Certainly making sure dependencies aren't too much of a burden is very important.

Looking forward to give this a spin soon :)

P.S. Another thought that crossed my mind is that you might want to let users configure which login method is primary/preferred & in case of social login/SAML/OIDC you could auto-redirect to the issuer/authority when clicking login - but that is a separe thing.

@ssddanbrown ssddanbrown added this to the Next Feature Release milestone Oct 13, 2021
@ssddanbrown
ssddanbrown merged commit 263384c into master Oct 16, 2021
@ssddanbrown
ssddanbrown deleted the oidc branch October 16, 2021 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants