Skip to content

How to use a 'signing key' as used by next-auth #389

Closed
@recurser

Description

I'm trying to use next-auth on the frontend backed by a Rails API. The JWT tokens generated by the frontend use a signingKey (see docs). The key looks like this:

$ jose newkey -s 256 -t oct -a HS512
{"kty":"oct","kid":"kigxq6S4B7X4-wTxbqEJMYLYVid-BjW4SZMMm6wSC3c","alg":"HS512","k":"ghBlGxKq9CcDYDG7XUHmquoBc-mrMXWfpZcPYnMihBQ"}

I can't get the tokens generated by the frontend to verify in Ruby (Signature verification raised), and I'm unsure how to plug this key into ruby-jwt. The tokens seem to verify ok in jwt.io. Any advice as to how I should use this kind of JSON key in addition to (or instead of?) the secret in ruby-jwt?

On the ruby side I'm doing this:

JWT.decode(token, secret, true, { algorithms: ['HS512'] })

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions