![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
hapi-auth-header
Advanced tools
Robust Authorization Header Auth Scheme for Hapi, with custom error reporting schema.
hapi Authorization header authentication scheme
Version 3.x of this plugin is compatible with Hapi 17 and higher only.
For Hapi 16, please continue to use version 2.x of this plugin.
Special thanks to @johnbrett for hapi-auth-bearer-token plugin, which this plugin used as scaffolding.
You might find that the hapi-auth-bearer-token plugin is all you need, which also allows for Bearer
supplied as a query param (this module does not). This plugin exists to handle the whole Authorization header, which allows comma delimited Authorization sources. This is useful if you need to validate more than one Authorization header field. For example, the API that this plugin was originally built for was gated by an API management proxy, which forwards traffic along with an "FD" Authorization header, added along with the "Bearer" header like so: Authorization: FD AF6C74D1-BBB2-4171-8EE3-7BE9356EB018, Bearer 12345678
This plugin is identical to hapi-auth-bearer-token plugin except that it will return tokens
as an object back to your callback rather than token
as the Bearer
field value (e.g. Authorization: FD AF6C74D1-BBB2-4171-8EE3-7BE9356EB018, Bearer 12345678
would result in your validate function being called with tokens set to
{
Bearer: 12345678,
FD: AF6C74D1-BBB2-4171-8EE3-7BE9356EB018
}
Authentication requires validating tokens passed by Authentication header. You can customize any arbitrary number of names for the Authorization header fields that you want to validate.
Bearer authentication requires validating a token passed in by either the bearer authorization header, or by an access_token query parameter. The 'auth-header'
scheme takes the following options:
validateFunc
- (required) An async validation function with the signature function(tokens)
where:
tokens
- an object containing each of the Authorization header keys.isValid
- true
if both the username was found and the password matched, otherwise false
.credentials
- a credentials object passed back to the application in request.auth.credentials
. Typically, credentials
are only
included when isValid
is true
, but there are cases when the application needs to know who tried to authenticate even when it fails
(e.g. with authentication mode 'try'
).options
- (optional) - there are currently no configuration options :)const Hapi = require('hapi');
const defaultHandler = (request, h) => {
return h.response('success');
};
const server = new Hapi.Server({
port: 3117,
host: 'localhost'
});
server.register(require('hapi-auth-header'), async (err) => {
server.auth.strategy('header', 'auth-header', {
validate: function( tokens ) {
// Use a real strategy here,
// e.g. send the token to an oauth validation API
if(tokens.Bearer === "1234" && tokens.oauth === "4321" ){
return [true, { token: tokens.bearer }]
} else {
return [false, { token: tokens.bearer }]
}
}
});
server.route({ method: 'GET', path: '/', handler: defaultHandler, options: { auth: 'header' } });
await server.start();
console.log('Server started at: ' + server.info);
});
FAQs
Robust Authorization Header Auth Scheme for Hapi, with custom error reporting schema.
The npm package hapi-auth-header receives a total of 14 weekly downloads. As such, hapi-auth-header popularity was classified as not popular.
We found that hapi-auth-header demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.