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

SimpleJWS verification fails if no iat claim #111

Open
mamciek opened this issue Nov 23, 2016 · 1 comment · May be fixed by #112
Open

SimpleJWS verification fails if no iat claim #111

mamciek opened this issue Nov 23, 2016 · 1 comment · May be fixed by #112

Comments

@mamciek
Copy link

mamciek commented Nov 23, 2016

According to JWT standard the 'iat' claim i optional. When decoding token (without 'iat') using SimpleJWS then verification of the signature fails. There is a function generateSigninInput in JWT class that return the input that the signature is verified against.

    public function generateSigninInput()
    {
        $base64payload = $this->encoder->encode(json_encode($this->getPayload(), JSON_UNESCAPED_SLASHES));
        $base64header = $this->encoder->encode(json_encode($this->getHeader(), JSON_UNESCAPED_SLASHES));
        return sprintf('%s.%s', $base64header, $base64payload);
    }

But when decoding token (without iat claim) with SimpleJWS, then 'iat' is automatically added to the decoded payload in setPayload method of SimpleJWS so the signinginput is different than was originally in token.

    public function setPayload(array $payload)
    {
        if (!isset($payload['iat'])) {
            $payload['iat'] = time();
        }
        return parent::setPayload($payload);
    }
@jbidzik
Copy link

jbidzik commented Nov 23, 2016

same problem here.
if we used a token generated by another system that does not had iat, signature verification fails.
Maybe adding iat claim must be only done on token creation. Or maybe not use iat at all.

@jbidzik jbidzik linked a pull request Nov 24, 2016 that will close this issue
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 a pull request may close this issue.

2 participants