patrickpissurno / fastify-esso

The easiest authentication plugin for Fastify, with built-in support for single sign-on (SSO)
https://npm.im/fastify-esso
MIT License
52 stars 6 forks source link

add authenticating as a function #21

Open hazeezet opened 9 months ago

hazeezet commented 9 months ago

When this plugin is used, it only validate through a preHandler hook

fastify.requireAuthentication(fastify);

But in a use case where by you need to validate without using a hook. maybe you just want to validate a header or cookie or query

a good example is a graphql application whereby using hook does not really fit it, you need to validate at resolver level rather than at route level.

so using it as a function will be nice, just by passing request and reply instance instead of fastify instance

await fastify.requireAuthentication(request, reply);
hazeezet commented 8 months ago

@patrickpissurno, please can you take a look.