web-token / jwt-framework

JWT Framework
MIT License
887 stars 105 forks source link

IssuedAtChecker, NotBeforeChecker and ExpirationTimeChecker documentation missing constructor #583

Open rwkymapcreator opened 1 month ago

rwkymapcreator commented 1 month ago

Description

The documentation here https://web-token.spomky-labs.com/the-components/claim-checker has

<?php

use Jose\Component\Checker\ClaimCheckerManager;
use Jose\Component\Checker;

$claimCheckerManager = new ClaimCheckerManager(
    [
        new Checker\IssuedAtChecker(),
        new Checker\NotBeforeChecker(),
        new Checker\ExpirationTimeChecker(),
        new Checker\AudienceChecker('Audience'),
    ]
);

However IssuedAtChecker has one required constructor argument

final readonly class IssuedAtChecker implements ClaimChecker, HeaderChecker                         
{                                                                                                   
    private const NAME = 'iat';                                                                     

    public function __construct(                                                                    
        private ClockInterface $clock,                                                              
        private int $allowedTimeDrift = 0,                                                          
        private bool $protectedHeaderOnly = false,                                                  
    ) {                                                                                             
    }    
rwkymapcreator commented 1 month ago

The same goes for NotBeforeChecker and ExpirationTimeChecker

Spomky commented 1 month ago

Hi,

Actually, the link refers to the v3.3 that is now outdated. Please refer to the last major version v4.0: https://web-token.spomky-labs.com/v/v4.0/the-components/header-checker

rwkymapcreator commented 1 month ago

Here's the same page on v4 https://web-token.spomky-labs.com/v/v4.0/the-components/claim-checker with the same issue

image

Spomky commented 1 month ago

Indeed, I only checked the header verification page and not the claim one. I will fix it ASAP