Hello, can anyone tell me how can I verify the jso...
# talk-kratos
b
Hello, can anyone tell me how can I verify the json web token converted from kratos session using php. now I can validate token when it generate by oauth2/token , so the problem I faced is when I convert sessions token to JWT it doesn’t work.
c
I don't think ORY session tokens are JWTs.
b
I can convert kratos session token to JWT , but when i try to validate using jwks it throws errors
c
Which jwks are you using?
Looking at the PR for tokenizing the session to JWT, it's unclear if it uses the JWKS from hydra, oathkeeper or a new one
b
however do you know how can i have same validation format in my middleware , jwt, kratos session ...
c
So you generated a JWKS yourself and added it to the kratos config?
b
exactly
c
what url are you using for JWKs in PHP/
b
I use this one .well-known/jwks.json and add in the one I created myself but now the issue I faced is : {“status”“failure”,“statusCode”1,“statusDescription”:“Key data must be for a public key”}
{"status":"failure","statusCode":1,"statusDescription":"Key data must be for a public key"}
Copy code
$jwks = file_get_contents(sprintf('%s/.well-known/jwks.json',env('ORY_HYDRA_ADMIN')));

$key = $hydraClientAdmin->get('/admin/keys/jwt-token-pqp');
$tokenJwk = json_decode($key->getBody()->getContents(), true);

$decodedJWKS = json_decode($jwks, true);

//$jwkConverter = new JWKConverter();
$decodedJWKS['keys'][] = $tokenJwk['keys'][0];

$decodedAccessToken = JWT::decode(
    $accessToken,
    JWK::parseKeySet($decodedJWKS)
);
c
does it look like a normal JWKS public key data, or does it include all the private key info?
b
I’m using laravel
c
Look like you're getting the hydra keys from the admin endpoints, not the kratos keys?
b
I’m on ory network the managed service
c
I think line 3 should read
json_decode($jwks->getBody()->getContents()
rather than starting with
$key
. See you're trying to use the hydra private keys rather than the public keys from the jwks well-known url.
b
I don’t get , but I’ll investigate deeply. Thanks a lot for your time