@berlingske-media/bm.node-module.auth_plugin v4.0.1
Plugin compatible with OAuth2.0 resource server
Generic usage
On application start
import init
function from lib/shared
and run
await init()
To sign your request
to another verified backend server sign your request with token import token getter with
import { getAccessToken } from 'lib/shared'
and use token as follow:
await request.get('/anything')
.set('Authorization', 'Bearer <TOKEN>');
.
Express integration
in order to integrate plugin with express app use this code snippet
import { verifyRequest } from '../lib/oauthExpressMiddleware';
// and then use as a middleware
app.use(verifyRequest);
// or validate single route with:
app.get('/', verifyRequest, (req, res) => {
res.status(StatusCodes.OK).send(ReasonPhrases.OK);
});
Hapi integration
in order to integrate plugin with hapi app see this code snippet
import { oauthPlugin } from '../lib/oauthHapiStrategy';
await server.register(oauthPlugin);
server.auth.default('oauth2');
server.route({
method: 'GET',
path: '/',
options: {
auth: 'oauth2'
},
handler: function (request, h) {
return 'welcome';
}
});
dont use default
if you want only "pre-route" validation, if so, just registering plugin allows you
to use it in route options.
More examples can be found in tests.
20 days ago
22 days ago
22 days ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
6 months ago
6 months ago
9 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago