-
Hey everyone, I'm trying to extend the JWT Builder class to allow a workaround method of addClaim() to utilize the currently private setClaim() method. I tried utilizing talal424's answer on the old forums of extending the builder class to create a method that will tap into the builder's native method of setting custom claims, but I am still getting a fatal error generated that the setClaim() method is private. Perhaps I'm missing something? Here is my extension class: use Phalcon\Security\JWT\Builder;
class CustomJWTBuilder extends Builder
{
public function addClaim(string $name, $value): Builder
{
return $this->setClaim($name, $value);
}
} And here is how I'm utilizing it: $builder = new CustomJWTBuilder($signer);
// Setup
$builder
->setAudience('https://targetdomain.tld')
->setContentType('application/json')
->setExpirationTime($expires)
->setIssuedAt($issued)
->setIssuer('https://issuer.tld')
->setNotBefore($notBefore)
->setSubject('Subject')
->setPassphrase($passphrase)
->addClaim('Test', '123')
;
// Phalcon\Security\JWT\Token\Token object
$tokenObject = $builder->getToken();
// The token
echo $tokenObject->getToken(); This is the error I'm getting:
Any help would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
/cc @niden |
Beta Was this translation helpful? Give feedback.
-
We will need to change the scope of @JMoodyFWD if it is not too much trouble can you open an issue and cc me on it so that I can resolve this? Thanks! |
Beta Was this translation helpful? Give feedback.
We will need to change the scope of
setClaim
because the extended class cannot see that method.@JMoodyFWD if it is not too much trouble can you open an issue and cc me on it so that I can resolve this?
Thanks!