Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/platformatic/mtls-auth
https://github.com/platformatic/mtls-auth
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/platformatic/mtls-auth
- Owner: platformatic
- License: apache-2.0
- Created: 2023-07-10T09:45:31.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-15T17:55:46.000Z (about 1 year ago)
- Last Synced: 2024-10-12T21:19:14.400Z (2 months ago)
- Language: JavaScript
- Size: 106 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### mtls-auth
Plugin to extract authentication information from mTLS certificate common name.
__Example:__
Common name: `payments.test.com`
```js
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`
```js
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
})
```