Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
@http-ext/plugin-auth
Advanced tools
A auth plugin for HttpExt.
This plugin takes care of handling authorization by:
Authorization
header with the given token automatically for each request matching a custom condition,401 Unauthorized
http responses.This plugins helps avoiding all the http interceptor boilerplate required to add the authorization token and detect token expiration.
Using matchers like matchOrigin
, we'll ensure that the token is sent to the right API.
This also helps using different tokens for different APIs in the same app.
The plugin requires @http-ext/core
and @http-ext/angular
to be installed.
yarn add @http-ext/plugin-cache @http-ext/core
or
npm install @http-ext/plugin-cache @http-ext/core
import { HttpExtModule } from '@http-ext/angular';
import { createAuthPlugin } from '@http-ext/plugin-auth';
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
HttpClientModule,
HttpExtModule.forRoot({
deps: [AuthService],
config: (authService: AuthService) =>
createAuthPlugin({
shouldHandleRequest: matchOrigin('https://secure-origin.com'),
token: authService.getToken(), // Returns an Observable<string>.
onUnauthorized: () => authService.markTokenExpired()
})
})
],
bootstrap: [AppComponent]
})
export class AppModule {}
You can give a partial configuration object it will be merged with default values.
Property | Type | Required | Default value | Description |
---|---|---|---|---|
token | Observable<string> | Yes | undefined | The bearer token that will be added to every matching request in the Authorization header. |
onUnauthorized | OnUnauthorized | No | undefined | A function executed when an unauthorized response is thrown. |
shouldHandleRequest | RequestCondition | No | matchOrigin('https://my-origin.com') | Predicate function to know which request the plugin should handle. |
To know more about the shouldHandleRequest
property check-out the conditional handling section.
FAQs
> A auth plugin for [HttpExt](https://github.com/jscutlery/http-ext).
The npm package @http-ext/plugin-auth receives a total of 0 weekly downloads. As such, @http-ext/plugin-auth popularity was classified as not popular.
We found that @http-ext/plugin-auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.