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

Nonce and max_age handling with new CookieStore class #395

Merged
merged 11 commits into from
Nov 14, 2019

Conversation

joshcanhelp
Copy link
Contributor

@joshcanhelp joshcanhelp commented Nov 11, 2019

Changes

Potentially breaking changes:

  • Add enforced nonce checking for ID tokens. Nonce value is stored automatically in cookies (default cookie name auth0_nonce) and required to be checked in ID tokens. All checking is handled in the SDK but some managed hosts require whitelisted cookies and/or specific cookie names so this could be breaking.

Other changes:

  • Add auth_store transient_store config option for ID token nonce handling; defaults to new CookieStore class (Edit: auth_store in this PR was changed to transient_store in Improve transient authorization data handling #397 pre-release)
  • Add max_age config option for Auth0 class to set a max_age URL parameter on all authorization requests.
  • Add leeway config option for Auth0 class to set an ID token time check leeway

Testing

Also went through a number of manual tests to ensure the default cookie setting and deleting was working.

  • This change adds test coverage
  • This change has been developed and tested on PHP 7.1 and 7.2

Checklist

  • All existing and new tests complete without errors.
  • The correct base branch is being used.

@joshcanhelp joshcanhelp changed the title Add CookieStore class Nonce and max_age handling with new CookieStore class Nov 11, 2019
@@ -27,15 +29,7 @@ class Auth0Test extends TestCase
*
* @var array
*/
public static $baseConfig = [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to move this to setUp to use a class for auth_store

*
* @var integer
*/
protected $maxAge;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Allows a max_age time to be set at the initialization level for all requests.

src/Auth0.php Outdated Show resolved Hide resolved
src/Auth0.php Outdated
@@ -613,8 +651,15 @@ public function setIdToken($idToken)
$sigVerifier = new SymmetricVerifier($this->clientSecret);
}

$verifierOptions = [
'nonce' => $this->authStore->get('nonce'),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the stored values are empty, null is returned and the check is skipped

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this is related to @stevehobbsdev 's question. Devs should not be able to skip this check. As far as I know, the only optional value here is max_age. For leeway you always have a default value of 60 secs, and for nonce you will either get the value set by the dev or one generated by you prior to initialize the auth.

Please make it required. Happy to discuss internally ⚡️

@joshcanhelp joshcanhelp marked this pull request as ready for review November 11, 2019 23:24
@joshcanhelp joshcanhelp requested a review from a team November 11, 2019 23:24
@joshcanhelp joshcanhelp added this to the 7.0.0 milestone Nov 11, 2019
Copy link

@stevehobbsdev stevehobbsdev left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple of comments for my own understanding.

src/Auth0.php Outdated Show resolved Hide resolved
src/Store/CookieStore.php Outdated Show resolved Hide resolved
src/Auth0.php Outdated Show resolved Hide resolved
src/Auth0.php Outdated
@@ -613,8 +651,15 @@ public function setIdToken($idToken)
$sigVerifier = new SymmetricVerifier($this->clientSecret);
}

$verifierOptions = [
'nonce' => $this->authStore->get('nonce'),
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this is related to @stevehobbsdev 's question. Devs should not be able to skip this check. As far as I know, the only optional value here is max_age. For leeway you always have a default value of 60 secs, and for nonce you will either get the value set by the dev or one generated by you prior to initialize the auth.

Please make it required. Happy to discuss internally ⚡️

src/Auth0.php Show resolved Hide resolved
src/Store/CookieStore.php Show resolved Hide resolved
src/Store/EmptyStore.php Show resolved Hide resolved
tests/Auth0Test.php Show resolved Hide resolved
@lbalmaceda
Copy link
Contributor

@joshcanhelp this is the main blocker on my review #395 (comment), the rest are observations or questions. Once you fix that, it should be ready to merge provided @stevehobbsdev agrees.

I basically added that blocker because your comment stated that the dev could be able to skip checks when desired. They shouldn't be able to skip any checks 👍

@joshcanhelp
Copy link
Contributor Author

@stevehobbsdev - Made a few fixes and corrections and added tests for CookieStore. I addressed all of @lbalmaceda's issues here as well.

@joshcanhelp joshcanhelp merged commit 02d5f28 into 7.0.0-dev Nov 14, 2019
@joshcanhelp joshcanhelp deleted the add-cookie-store branch November 14, 2019 14:31
@joshcanhelp joshcanhelp restored the add-cookie-store branch November 14, 2019 14:31
@joshcanhelp joshcanhelp deleted the add-cookie-store branch November 14, 2019 14:31
@github-actions
Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 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.

3 participants