Skip to content

Conversation

acomarcho
Copy link

@acomarcho acomarcho commented Oct 14, 2025

Hi, first of all, thank you for the great library!

I made this PR as I was having some troubles navigating around the documentation. For the context:

  1. I am using this library in a project I'm working at right now.
  2. I was having some problems with clock drifts, some of my clients were sending in iat that are faster than my server time.
  3. I wanted to fix this by using the leeway property, but got confused as in "does this library support it or not?"
  4. Documentations for leeway only exists for nbf and exp, so I was thinking "oh, then, leeway doesn't work for iat"
  5. I cloned the codebase to take a look at myself and found out that in the function _validate_iat actually does! (see appendix A)
  6. I figured out, "it probably would be helpful if the documentation states this."
  7. Then I also realized that in the API docs it's stating that leeway is only for expiration which might be misleading.

See appendix B for the screenshots of the updated documentation.

Apologies for any mistakes if I'm contributing the wrong way (do I need to create an issue first, etc.) - this is my first time contributing to one. This PR was mostly inspired by #1034 which adds documentation for nbf.

Appendix A

    def _validate_iat(
        self,
        payload: dict[str, Any],
        now: float,
        leeway: float,
    ) -> None:
        try:
            iat = int(payload["iat"])
        except ValueError:
            raise InvalidIssuedAtError(
                "Issued At claim (iat) must be an integer."
            ) from None
        if iat > (now + leeway): # <-- leeway validation is done for iat too!
            raise ImmatureSignatureError("The token is not yet valid (iat)")

Appendix B

image image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant