Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@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 5 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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.