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

RFC7519 JWTClaims.validate_iat() doesn't utilise the leeway parameter #564

Closed
dhallam opened this issue Jul 20, 2023 · 5 comments
Closed
Assignees
Labels

Comments

@dhallam
Copy link
Contributor

dhallam commented Jul 20, 2023

Describe the bug

The JWTClaims.validate_iat() function in authlib/jose/rfc7519/claims.py doesn't utilise the leeway parameter. The function should validate that the iat claim is "reasonable" relative to the current time.

Expected behavior

The validate_iat() function should raise an InvalidTokenError if the iat claim value is outside the now ± leeway window.

The validate_iat() function should raise an InvalidTokenError if the iat claim value is after now + leeway.

Environment:

  • OS: ubuntu 22.04
  • Python Version: 3.10.12
  • Authlib Version: 1.2.1
@lepture
Copy link
Owner

lepture commented Jul 20, 2023

@dhallam I don't understand why? iat is just the time that this token is issued. According to the spec:

        The "iat" (issued at) claim identifies the time at which the JWT was
        issued.  This claim can be used to determine the age of the JWT.  Its
        value MUST be a number containing a NumericDate value.  Use of this
        claim is OPTIONAL.

I think you are mistaken it with exp and nbf.

@lepture lepture closed this as completed Jul 20, 2023
@dhallam
Copy link
Contributor Author

dhallam commented Jul 20, 2023

@lepture What I'm looking at is verifying that the iat is not set to a value that is (too far) in the future, so the ± in my original post is incorrect. I've edited the original "expected behaviour" section in the original post to make it clearer.

As mentioned in square/go-jose#216 there is a test case for an issue date that is set in the future at https://cloud.google.com/iap/docs/query-parameters-and-headers-howto#testing_jwt_verification.

@lepture
Copy link
Owner

lepture commented Jul 20, 2023

@dhallam Oh, you mean iat should not be a future time?

lepture added a commit to authlib/joserfc that referenced this issue Jul 20, 2023
@dhallam
Copy link
Contributor Author

dhallam commented Jul 20, 2023

Yes, sorry - I could have been clearer :-) PR raised for review #565

@dhallam
Copy link
Contributor Author

dhallam commented Jul 20, 2023

I see you've already pushed a PR - will let you run with the best approach. Ping me if you need any feedback. Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants