Angular 2/4 Authentication

This package provides major missing feature in angular2: Authentication.

Package is given in completely 100% pure TypeScript.

Package is strictly dependent on sibling ng4-http module, so make sure to use it as http module (it's actually imported already in this module.

Authentication module

Authentication modules provides ability to attach authentication token automatically to the headers (through http interceptors), refresh token functionality, guards for protected or public pages and more.


  1. Import AuthService interface to implement it with your custom Authentication service, e.g.:
  1. Specify PublicGuard for public routes and ProtectedGuard for protected respectively, e.g.:
  1. Create additional AuthenticationModule and provide important providers and imports, e.g.:

where, * PROTECTED_FALLBACK_PAGE_URI - main protected page to be redirected to, in case if user will reach public route, that is protected by PublicGuard and will be authenticated

  • PUBLIC_FALLBACK_PAGE_URI - main public page to be redirected to, in case if user will reach protected route, that is protected by ProtectedGuard and won't be authenticated

  • AUTH_SERVICE - Authentication service token providers

  1. Provide your AuthenticationModule in your AppModule
comments powered by Disqus
This page was last updated over 1 year ago.