Gathering detailed insights and metrics for @auth0/angular-jwt
Gathering detailed insights and metrics for @auth0/angular-jwt
Gathering detailed insights and metrics for @auth0/angular-jwt
Gathering detailed insights and metrics for @auth0/angular-jwt
jwt-decode
Decode JWT tokens, mostly useful for browser applications.
jose
JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes
passport-jwt
Passport authentication strategy using JSON Web Tokens
jsonwebtoken
JSON Web Token implementation (symmetric and asymmetric)
Helper library for handling JWTs in Angular apps
npm install @auth0/angular-jwt
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
2,633 Stars
529 Commits
485 Forks
86 Watching
11 Branches
102 Contributors
Updated on 27 Nov 2024
TypeScript (93.24%)
JavaScript (5.92%)
HTML (0.66%)
SCSS (0.18%)
Cumulative downloads
Total Downloads
Last day
-11.4%
40,363
Compared to previous day
Last week
-4.5%
215,629
Compared to previous week
Last month
15.1%
928,093
Compared to previous month
Last year
9%
9,879,967
Compared to previous year
1
1
:books: Documentation - :rocket: Getting Started - :computer: API Reference - :speech_balloon: Feedback
This library provides an HttpInterceptor
which automatically attaches a JSON Web Token to HttpClient
requests.
This library does not have any functionality for (or opinion about) implementing user authentication and retrieving JWTs to begin with. Those details will vary depending on your setup, but in most cases, you will use a regular HTTP request to authenticate your users and then save their JWTs in local storage or in a cookie if successful.
This project only supports the actively supported versions of Angular as stated in the Angular documentation. Whilst other versions might be compatible they are not actively supported
1# installation with npm 2npm install @auth0/angular-jwt 3 4# installation with yarn 5yarn add @auth0/angular-jwt
Import the JwtModule
module and add it to your imports list. Call the forRoot
method and provide a tokenGetter
function. You must also add any domains to the allowedDomains
, that you want to make requests to by specifying an allowedDomains
array.
Be sure to import the HttpClientModule
as well.
1import { JwtModule } from "@auth0/angular-jwt"; 2import { HttpClientModule } from "@angular/common/http"; 3 4export function tokenGetter() { 5 return localStorage.getItem("access_token"); 6} 7 8@NgModule({ 9 bootstrap: [AppComponent], 10 imports: [ 11 // ... 12 HttpClientModule, 13 JwtModule.forRoot({ 14 config: { 15 tokenGetter: tokenGetter, 16 allowedDomains: ["example.com"], 17 disallowedRoutes: ["http://example.com/examplebadroute/"], 18 }, 19 }), 20 ], 21}) 22export class AppModule {}
Any requests sent using Angular's HttpClient
will automatically have a token attached as an Authorization
header.
1import { HttpClient } from "@angular/common/http"; 2 3export class AppComponent { 4 constructor(public http: HttpClient) {} 5 6 ping() { 7 this.http.get("http://example.com/api/things").subscribe( 8 (data) => console.log(data), 9 (err) => console.log(err) 10 ); 11 } 12}
If you are using bootstrapApplication
to bootstrap your application using a standalone component, you will need a slightly different way to integrate our SDK:
1import { JwtModule } from "@auth0/angular-jwt"; 2import { provideHttpClient, withInterceptorsFromDi } from "@angular/common/http"; 3 4export function tokenGetter() { 5 return localStorage.getItem("access_token"); 6} 7 8bootstrapApplication(AppComponent, { 9 providers: [ 10 // ... 11 importProvidersFrom( 12 JwtModule.forRoot({ 13 config: { 14 tokenGetter: tokenGetter, 15 allowedDomains: ["example.com"], 16 disallowedRoutes: ["http://example.com/examplebadroute/"], 17 }, 18 }), 19 ), 20 provideHttpClient( 21 withInterceptorsFromDi() 22 ), 23 ], 24});
As you can see, the differences are that:
importProvidersFrom
.provideHttpClient
needs to be called with withInterceptorsFromDi
.Read our API reference to get a better understanding on how to use this SDK.
We appreciate feedback and contribution to this repo! Before you get started, please see the following:
To provide feedback or report a bug, please raise an issue on our issue tracker.
Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.
Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout Why Auth0?
This project is licensed under the MIT license. See the LICENSE file for more info.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
SAST tool detected
Details
Reason
Found 13/14 approved changesets -- score normalized to 9
Reason
dependency not pinned by hash detected -- score normalized to 7
Details
Reason
branch protection is not maximal on development and all release branches
Details
Reason
2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
27 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More