FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login
    1. Home
    2. mark 0
    3. Best
    M
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 1
    • Controversial 0
    • Groups 0

    Best posts made by mark 0

    • FusionAuth / Fastify

      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...

      posted in Q&A
      M
      mark 0