Skip to content

nbf validation issue #20

Open
Open
@bolner

Description

@bolner

Hi, in the current version:

['nbf', $this->maxAge - $this->leeway, static::ERROR_TOKEN_NOT_NOW, 'Not now'],

That line should be:

['nbf', -$this->leeway, static::ERROR_TOKEN_NOT_NOW, 'Not now'],

When checking the nbf ("not before") time, then the "max age" value is not relevant.

Let's see an example:

  • Current time = 2020-10-08 12:00:00
  • Max age = 3 hours = 10800 sec
  • nbf = 2020-10-08 11:00:00 (will be valid after this time)
  • leeway = 5 sec (allow max 5 sec misalignment of server clocks)

Then the current code would say:

  • The token fails the nbf check because:
    • reference value = 2020-10-08 11:00:00 + 3 hours - 5 sec = 2020-10-08 13:59:55
    • And the current time still hasn't reached this value yet.

But it should only subtract the leeway, and leave the irrelevant "max age" out of this:

  • The nbf check is successful, because:
    • reference value = 2020-10-08 11:00:00 - 5 sec = 2020-10-08 10:59:55
    • And the current time is greater than this value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions