You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP

a4-http-authorization-interceptor

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a4-http-authorization-interceptor

Angular 6 Http Authorization Interceptor

6.0.2
Version published
Weekly downloads
11
-57.69%
Maintainers
1
Weekly downloads
 
Created

a4-http-authorization-interceptor

Angular 6 Http Authorization Interceptor

How-To

Install

npm install a4-http-authorization-interceptor

app.module.ts

  • Add HttpAuthorizationModule to imports of the app.module.ts.

...
import { HttpAuthorizationModule } from 'a4-http-authorization';
...

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    ...,
    HttpAuthorizationModule,
    ...
  ],
  ...
})

Inject the service

constructor(private httpAuthorizationService: HttpAuthorizationService) { }
this.httpAuthorizationService.setTokenCookieName('oauth-cookie');

Set Authroization Header Call Back

this.httpAuthorizationService.setHttpAuthorizationCallback(req => {
  // your logic here

  return true; // return true to allow injector to inject the authorization header
               // return false and injector will not inject the authorization header
});

Get Authorization Header

const header = this.httpAuthorizationService.getAuthorizationHeader();

This will return Bearer <token> if cookie is found, otherwise it returns an empty string ('').

FAQs

Package last updated on 19 May 2018

Did you know?

Socket

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.

Install

Related posts