Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve OIDC Compliance #734

Merged
merged 6 commits into from
Dec 2, 2019
Merged

Improve OIDC Compliance #734

merged 6 commits into from
Dec 2, 2019

Conversation

joshcanhelp
Copy link
Contributor

@joshcanhelp joshcanhelp commented Nov 23, 2019

Changes

This update improves the SDK support for OpenID Connect. In particular, it modifies the sign in verification phase by substituting backchannel based checks with id_token validation.

Note to reviewers: This re-uses the majority of the PHP SDK token verifier work. Please see this draft PR to review the differences between the core verification classes. ~540 added lines are represented in that diff.

References

Testing

Manual testing:

  1. In wp-admin > Auth0 > Settings, turn Implicit login flow off in settings and universal login page on.
  2. Logout then log back in.
  3. Make sure the redirect response from WP includes both state and nonce cookies:

Screenshot 2019-11-25 09 40 04

  1. Make sure the /authorize URL has all the expected params:

Screenshot 2019-11-25 11 06 48

  1. Log in at Auth0
  2. Make sure you're logged in with no errors in the plugin error log
  3. Make sure that the nonce and state cookies are deleted on the callback response:

Screenshot 2019-11-25 12 04 27

  • I included manual testing steps above, if applicable
  • This change adds unit test coverage
  • This change has been tested on WP 5.3 and PHP 7.0

Checklist

  • All existing and new tests complete without errors
  • All code quality tools/guidelines in the Contribution guide have been run/followed
  • All relevant assets have been compiled as directed in the Contribution guide, if applicable
  • All active GitHub CI checks have passed

@@ -117,6 +117,33 @@ function wp_auth0_can_show_wp_login_form() {
return false;
}

/**
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of these functions were pulled from the old JWT library.

@@ -4,7 +4,8 @@
"homepage": "https://auth0.com/wordpress",
"license": "GPLv2",
"require": {
"php": "^7.0"
"php": "^7.0",
"lcobucci/jwt": "^3.3.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous library was not managed with Composer.

@@ -0,0 +1,54 @@
<?php
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See this diff for changes from approved PHP SDK ones.

@@ -0,0 +1,265 @@
<?php
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See this diff for changes from approved PHP SDK ones.

@@ -0,0 +1,76 @@
<?php
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See this diff for changes from approved PHP SDK ones.

@@ -0,0 +1,87 @@
<?php
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See this diff for changes from approved PHP SDK ones.

@@ -0,0 +1,55 @@
<?php
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See this diff for changes from approved PHP SDK ones.

@joshcanhelp joshcanhelp marked this pull request as ready for review November 25, 2019 21:33
@joshcanhelp joshcanhelp requested a review from a team November 25, 2019 21:33
@joshcanhelp joshcanhelp mentioned this pull request Nov 26, 2019
5 tasks
Copy link
Contributor

@lbalmaceda lbalmaceda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general. Please pay attention to the claim error messages. Should be wrapping the expected/received values between ( ) rather than " ". I see you're mixing them.

.circleci/config.yml Show resolved Hide resolved
lib/WP_Auth0_LoginManager.php Show resolved Hide resolved
$sigVerifier = new WP_Auth0_AsymmetricVerifier( $jwks );
} elseif ( 'HS256' === $this->a0_options->get( 'client_signing_algorithm' ) ) {
$sigVerifier = new WP_Auth0_SymmetricVerifier( $this->a0_options->get( 'client_secret' ) );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"else" scenario????

Also, you're doing $this->a0_options->get( 'client_signing_algorithm' ) twice. Seems like it can be extracted. Does it have performance impact?

lib/WP_Auth0_LoginManager.php Show resolved Hide resolved
lib/admin/WP_Auth0_Admin_Advanced.php Show resolved Hide resolved
protected function checkSignature( Token $token ) : bool {
$tokenKid = $token->getHeader( 'kid', false );
if ( ! array_key_exists( $tokenKid, $this->jwks ) ) {
throw new WP_Auth0_InvalidIdTokenException( 'ID token key ID "' . $tokenKid . '" was not found in the JWKS' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be

Could not find a public key for Key ID (kid) "${decoded.header.kid}"

tests/testLoginManagerAuthParams.php Show resolved Hide resolved
@joshcanhelp
Copy link
Contributor Author

@lbalmaceda

Please pay attention to the claim error messages. Should be wrapping the expected/received values between ( ) rather than " ". I see you're mixing them.

It looks like that was mapped over from the PHP SDK. We'll extract this out into it's own library in Phase 2 so this is consistent everywhere.

@joshcanhelp joshcanhelp merged commit 1381fb1 into master Dec 2, 2019
@joshcanhelp joshcanhelp deleted the improved-oidc-compliance branch December 16, 2019 19:00
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants