@platformatic/mtls-auth

1.2.1 • Public • Published

mtls-auth

Plugin to extract authentication information from mTLS certificate common name.

Example:

Common name: payments.test.com

const app = fastify(/* tls certs */)

app.register(mtlsAuthPlugin, {
  mtlsDomain: 'test.com'
})

app.get('/test', async (request) => {
  const session = request.getMtlsAuth()
  console.log(session['X-PLATFORMATIC-ROLE']) // payments
})

Common name: e4a123f8-1f12-11ee-be56-0242ac120002.clients.test.com

const app = fastify(/* tls certs */)

app.register(mtlsAuthPlugin, {
  mtlsClientsRole: 'clients',
  mtlsDomain: 'test.com'
})

app.get('/test', async (request) => {
  const session = request.getMtlsAuth()
  console.log(session['X-PLATFORMATIC-ROLE']) // clients
  console.log(session['X-PLATFORMATIC-WORKSPACE-ID']) // e4a123f8-1f12-11ee-be56-0242ac120002
})

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.2.10latest

Version History

VersionDownloads (Last 7 Days)Published
1.2.10
1.2.00
1.1.00
1.0.00

Package Sidebar

Install

npm i @platformatic/mtls-auth

Weekly Downloads

0

Version

1.2.1

License

Apache-2.0

Unpacked Size

32.1 kB

Total Files

16

Last publish

Collaborators

  • qard
  • shogun_panda
  • antoniosonis
  • mzugm
  • leorossi
  • marcopiraccini
  • ivan-tymoshenko
  • matteo.collina