src/Auth/JwtAuth.php
/**
     * Create JSON web token.
     *
     * @param User $user
     * @param array $requestedScopes Requested scopes
     * @return string The JWT
     */
Create JSON web token.
@param User $user
@param array $requestedScopes Requested scopes
@return string The JWT
Create JSON web token . @param User $user @param array $requestedScopes Requested scopes @return string The JWT
public function createJwt(User $user, array $requestedScopes = Role::ROLES): string
    {
        $issuedAt = Chronos::now()->getTimestamp();
        (!in_array(Role::ROLE_READER, $requestedScopes))
            ? $requestedScopes[] = Role::ROLE_READER
            : null;
        $awardedScopes = array_values(array_intersect($requestedScopes, $user->getRoles()));
        return (new Builder())->issuedBy($this->issuer)
            ->identifiedBy(Uuid::uuid4()->toString(), true)
            ->issuedAt($issuedAt) 
            ->canOnlyBeUsedAfter($issuedAt)
            ->expiresAt($issuedAt + $this->lifetime)
            ->withClaim('aud', $this->clientId) 
            ->withClaim('uid', $user->getId())
            ->withClaim('username', $user->getUsername())
            ->withClaim('scopes', $awardedScopes)
            ->getToken($this->signer, new Key($this->privateKey));
    }
public function createJwt ( User $ user , array $ requestedScopes = Role :: ROLES ) : string { $ issuedAt = Chronos :: now ( ) -> getTimestamp ( ) ; ( ! in_array ( Role :: ROLE_READER , $ requestedScopes ) ) ? $ requestedScopes [ ] = Role :: ROLE_READER : null ; $ awardedScopes = array_values ( array_intersect ( $ requestedScopes , $ user -> getRoles ( ) ) ) ; return ( new Builder ( ) ) -> issuedBy ( $ this -> issuer ) -> identifiedBy ( Uuid :: uuid4 ( ) -> toString ( ) , true ) -> issuedAt ( $ issuedAt ) -> canOnlyBeUsedAfter ( $ issuedAt ) -> expiresAt ( $ issuedAt + $ this -> lifetime ) -> withClaim ( 'aud' , $ this -> clientId ) -> withClaim ( 'uid' , $ user -> getId ( ) ) -> withClaim ( 'username' , $ user -> getUsername ( ) ) -> withClaim ( 'scopes' , $ awardedScopes ) -> getToken ( $ this -> signer , new Key ( $ this -> privateKey ) ) ; }
Create JSON web token.
Create JSON web token .
// (JWT ID) Claim, a unique identifier for the JWT // the time at which the JWT was issued // Audience