-
Does anyone have their (node) api service protected by FusionAuth using fastify? I have a simple POC that works with auth0 and the api is protected fairly easily with the below code:
// get variables from environment / enable auth0 fastify.register(require('fastify-auth0-verify'), { domain: process.env.AUTH0_DOMAIN, secret: process.env.AUTH0_SECRET }); // Actually turns on auth0 fastify.addHook("onRequest", async (request, reply) => { try { await request.jwtVerify() } catch (err) { reply.send(err) } });With the above code I can fairly easily grab the bearer token and pass that into curl (curl -H "Authorization: Bearer ${TOKEN}" ${SRV}/apiV1/users) for both production/testing purposes. If the bearer token is not valid it fails at the request level.
We're not that far along that I couldn't recode this into express to test the differences between the systems, but as it's working with fastify...
-
I have not done this, but from looking at the Fastify JWT library, it looks pretty straight forward:
https://github.com/fastify/fastify-jwt#options
Since there's no Fastify FusionAuth integration, you need to pass the public and private key if you want to verify and sign the JWTs, respectively. Since FusionAuth is creating the JWT, in theory you could just pass the public key of an RSA keypair, since you'll never need to sign the JWT (haven't tested that though).
To add the keys to FusionAuth, you'll want to use Keymaster: https://fusionauth.io/docs/v1/tech/core-concepts/key-master
Hope that helps.
-
D dan moved this topic from Q&A on
-
D dan moved this topic from Frequently Asked Questions (FAQ) on
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login