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

fix: issuedAt now validated with leeway in Oauth2ExpirationIssuedAtValidationRule #3728

Merged

Conversation

richardtreier
Copy link
Contributor

@richardtreier richardtreier commented Dec 21, 2023

What this PR changes/adds

As discussed here, added a configurable leeway to the validation of the issuedAt claim in oauth2-core.

Why it does that

The validation was added due to the sensitivity to clock skew of the aforementioned issuedAt claim.

See the #3692 for more detail.

Further notes

  • Added no validation for the expiresAt claim as it is less sensitive to clock skew.

Linked Issue(s)

Closes #3692

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

We are always happy to welcome new contributors ❤️ To make things easier for everyone, please make sure to follow our contribution guidelines, check if you have already signed the ECA, and relate this pull request to an existing issue or discussion.

Copy link
Contributor

@jimmarino jimmarino left a comment

Choose a reason for hiding this comment

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

Please have the validation leeway an opt-in and adjust the tests accordingly. Also include a test for the case where the validation leeway is set but has been exceeded.

@richardtreier richardtreier force-pushed the 2023-12-21-oauth2-validation-leeway branch from e2b19c9 to 8f910ab Compare December 21, 2023 09:15
@richardtreier
Copy link
Contributor Author

richardtreier commented Dec 21, 2023

Will post the changes in a sec.

I'd like to warn against not enabling a reasonable leeway (2s-5s) by default:

  • Rounding of dates is within-spec in JWT.
  • Rounding of dates, whether to round or not is implementation specific.
  • Rounding direction of dates is platform and implementation specific.
  • Our DAPS is built with Keycloak, so I'd trust them to do JWT by the letter. Same with the Azure cloud, I'd also assume them to do things reasonably.

This error is almost impossible to debug, as it happens only in production.

So I am afraid that keeping this leeway opt-in rather than opt-out might cause people to run into issues they deem impossible to debug and just drop their work. I would personally also argue against a configurability, as any clock skew beyond 1 or 2s (with rounding) could be considered out-of-scope for the eclipse edc connector to deal with.

@richardtreier richardtreier marked this pull request as ready for review December 21, 2023 09:44
@richardtreier
Copy link
Contributor Author

I updated both the default to 0 and the tests to be more explicit.

@jimmarino
Copy link
Contributor

Will post the changes in a sec.

I'd like to warn against not enabling a reasonable leeway (2s-5s) by default:

  • Rounding of dates is within-spec in JWT.
  • Rounding of dates, whether to round or not is implementation specific.
  • Rounding direction of dates is platform and implementation specific.
  • Our DAPS is built with Keycloak, so I'd trust them to do JWT by the letter. Same with the Azure cloud, I'd also assume them to do things reasonably.

This error is almost impossible to debug, as it happens only in production.

So I am afraid that keeping this leeway opt-in rather than opt-out might cause people to run into issues they deem impossible to debug and just drop their work. I would personally also argue against a configurability, as any clock skew beyond 1 or 2s (with rounding) could be considered out-of-scope for the eclipse edc connector to deal with.

This needs to be an explicit security decision by the operator. We can issue an INFO (not warning, since that pollutes the log) in the case that this is not set.

@richardtreier
Copy link
Contributor Author

I added a warning logged with INFO.

@richardtreier
Copy link
Contributor Author

The code style + message are fixed now.

@richardtreier richardtreier force-pushed the 2023-12-21-oauth2-validation-leeway branch from 57a840c to 5f6c547 Compare December 21, 2023 13:59
@richardtreier
Copy link
Contributor Author

Oh, I had that overlooked. Should be fixed now.

@richardtreier
Copy link
Contributor Author

I shortened the variables in question.

@richardtreier
Copy link
Contributor Author

The Setting annotations were updated to use their latest API.

The Apache 2.0 license headers of files that I touched were also updated, I hope correctly. Is this still the way things are done?

@ndr-brt ndr-brt added the enhancement New feature or request label Dec 22, 2023
Copy link
Member

@ndr-brt ndr-brt left a comment

Choose a reason for hiding this comment

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

as long as checkstyle does not complain about the headers, they are ok.

please update the dependencies file then we'll be ready to go (@jimmarino already approved)

@richardtreier
Copy link
Contributor Author

The DEPENDENCIES file was updated with the contents output by the CI.

@ndr-brt ndr-brt merged commit dec71ba into eclipse-edc:main Dec 22, 2023
17 checks passed
@richardtreier richardtreier deleted the 2023-12-21-oauth2-validation-leeway branch December 26, 2023 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Oauth2ExpirationIssuedAtValidationRule "issuedAt" vs "now" should have 1-5s leeway
3 participants