tuupola / slim-jwt-auth

PSR-7 and PSR-15 JWT Authentication Middleware
https://appelsiini.net/projects/slim-jwt-auth
MIT License
821 stars 140 forks source link

This works with public keys? #221

Closed kosciuk closed 2 years ago

kosciuk commented 2 years ago

Hi, I was using oauth server from https://oauth2.thephpleague.com/installation/ with public and private keys, but using the public key as secret with file_get_contents didn't work.

tuupola commented 2 years ago

Is it uses rsa256 then you should be able to use something like:

$app = new Slim\App;

$app->add(new Tuupola\Middleware\JwtAuthentication([
    "secret" => $publickey
    "algorithm" => ["RS256"]
]));

You can find example of how to generate the token in firebase/php-jwt README. This middleware uses firebase/php-jwt for decoding the token.

kosciuk commented 2 years ago

It works! Thanks!

But I think I will continue with the oauth server