SkeLLLa / fastify-metrics

Prometheus metrics exporter for Fastify
https://savelife.in.ua/en/donate-en/
MIT License
96 stars 33 forks source link

auth support #62

Closed kibertoad closed 1 year ago

kibertoad commented 2 years ago

It would be great to support authentication for scraping requests.

api proposal:

  app.register(fastifyMetrics, {
    endpoint: '/metrics',
    authFn: (req) => { return req.body.apiKey === 'myPassphrase' }
  })
SkeLLLa commented 2 years ago

It's already supported, see example in https://github.com/SkeLLLa/fastify-metrics/blob/master/src/__tests__/endpoint-object.spec.ts

You can pass fastify route configuration object and do auth in preHandler for example.

SkeLLLa commented 1 year ago

@kibertoad did previous comment help you solving issue?

SkeLLLa commented 1 year ago

Closing this since it's already possible with this API. Feel free to reopen if you need more details or functionality.