@auth0/auth0-angular 1.10.1 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,32 +1,30 @@
1
- ![Stage: Stable Release](https://img.shields.io/badge/stage-stable-green)
2
- ![Release](https://img.shields.io/github/v/release/auth0/auth0-angular)
3
- [![CircleCI](https://img.shields.io/circleci/build/github/auth0/auth0-angular)](https://circleci.com/gh/auth0/auth0-angular)
1
+ ![Auth0 SDK for Angular Single Page Applications](https://cdn.auth0.com/website/sdks/banners/auth0-angular-banner.png)
2
+
3
+ A library for integrating [Auth0](https://auth0.com) into an Angular application.
4
+
5
+ ![Release](https://img.shields.io/npm/v/@auth0/auth0-angular)
4
6
  [![Codecov](https://img.shields.io/codecov/c/github/auth0/auth0-angular)](https://codecov.io/gh/auth0/auth0-angular)
5
7
  ![Downloads](https://img.shields.io/npm/dw/@auth0/auth0-angular)
8
+ [![License](https://img.shields.io/:license-MIT-blue.svg?style=flat)](https://opensource.org/licenses/MIT)
9
+ [![CircleCI](https://img.shields.io/circleci/build/github/auth0/auth0-angular)](https://circleci.com/gh/auth0/auth0-angular)
6
10
 
7
- # Auth0 Angular SDK
11
+ 📚 [Documentation](#documentation) - 🚀 [Getting Started](#getting-started) - 💻 [API Reference](#api-reference) - 💬 [Feedback](#feedback)
8
12
 
9
- A library for integrating [Auth0](https://auth0.com) into an Angular 9+ application.
13
+ ## Documentation
10
14
 
11
- ## Table of Contents
15
+ - [Quickstart](https://auth0.com/docs/quickstart/spa/angular) - our interactive guide for quickly adding login, logout and user information to an Angular app using Auth0.
16
+ - [Sample App](https://github.com/auth0-samples/auth0-angular-samples/tree/master/Sample-01) - a full-fledged Angular application integrated with Auth0.
17
+ - [FAQs](https://github.com/auth0/auth0-angular/tree/master/FAQ.md) - frequently asked questions about the auth0-angular SDK.
18
+ - [Examples](https://github.com/auth0/auth0-angular/tree/master/EXAMPLES.md) - code samples for common Angular authentication scenario's.
19
+ - [Docs site](https://www.auth0.com/docs) - explore our docs site and learn more about Auth0.
12
20
 
13
- - [Documentation](#documentation)
14
- - [Installation](#installation)
15
- - [Getting Started](#getting-started)
16
- - [Angular Universal](#angular-universal)
17
- - [Development](#development)
18
- - [Contributing](#contributing)
19
- - [Support + Feedback](#support--feedback)
20
- - [Vulnerability Reporting](#vulnerability-reporting)
21
- - [What is Auth0](#what-is-auth0)
22
- - [License](#license)
21
+ ## Getting started
23
22
 
24
- ## Documentation
23
+ ### Requirements
25
24
 
26
- - [API Reference](https://auth0.github.io/auth0-angular/)
27
- - [Quickstart Guide](https://auth0.com/docs/quickstart/spa/angular-next)
25
+ This project only supports the [actively supported versions of Angular as stated in the Angular documentation](https://angular.io/guide/releases#actively-supported-versions). Whilst other versions might be compatible they are not actively supported.
28
26
 
29
- ## Installation
27
+ ### Installation
30
28
 
31
29
  Using npm:
32
30
 
@@ -40,363 +38,52 @@ We also have `ng-add` support, so the library can also be installed using the An
40
38
  ng add @auth0/auth0-angular
41
39
  ```
42
40
 
43
- ## Getting Started
44
-
45
- - [Register the authentication module](#register-the-authentication-module)
46
- - [Add login to your application](#add-login-to-your-application)
47
- - [Add logout to your application](#add-logout-to-your-application)
48
- - [Display the user profile](#display-the-user-profile)
49
- - [Protect a route](#protect-a-route)
50
- - [Call an API](#call-an-api)
51
- - [Dynamic configuration](#dynamic-configuration)
52
- - [Using multiple OAuth providers](#using-multiple-oauth-providers)
53
-
54
- ### Register the authentication module
55
-
56
- Install the SDK into your application by importing `AuthModule` and configuring with your Auth0 domain and client ID:
57
-
58
- ```js
59
- import { BrowserModule } from '@angular/platform-browser';
60
- import { NgModule } from '@angular/core';
61
- import { AppComponent } from './app.component';
62
-
63
- // Import the module from the SDK
64
- import { AuthModule } from '@auth0/auth0-angular';
65
-
66
- @NgModule({
67
- declarations: [AppComponent],
68
- imports: [
69
- BrowserModule,
70
-
71
- // Import the module into the application, with configuration
72
- AuthModule.forRoot({
73
- domain: 'YOUR_AUTH0_DOMAIN',
74
- clientId: 'YOUR_AUTH0_CLIENT_ID',
75
- }),
76
- ],
77
-
78
- bootstrap: [AppComponent],
79
- })
80
- export class AppModule {}
81
- ```
82
-
83
- ### Add login to your application
84
-
85
- Next, inject the `AuthService` service into a component where you intend to provide the functionality to log in, by adding the `AuthService` type to your constructor. Then, provide a `loginWithRedirect()` method and call `this.auth.loginWithRedirect()` to log the user into the application.
86
-
87
- ```js
88
- import { Component } from '@angular/core';
89
-
90
- // Import the AuthService type from the SDK
91
- import { AuthService } from '@auth0/auth0-angular';
92
-
93
- @Component({
94
- selector: 'app-root',
95
- templateUrl: './app.component.html',
96
- styleUrls: ['./app.component.css'],
97
- })
98
- export class AppComponent {
99
- title = 'My App';
100
-
101
- // Inject the authentication service into your component through the constructor
102
- constructor(public auth: AuthService) {}
103
-
104
- loginWithRedirect(): void {
105
- // Call this to redirect the user to the login page
106
- this.auth.loginWithRedirect();
107
- }
108
- }
109
- ```
110
-
111
- By default the application will ask Auth0 will redirect back to the root URL of your application after authentication, but this can be configured by setting the [`redirectUri` option](https://auth0.github.io/auth0-angular/interfaces/authconfig.html#redirecturi).
41
+ ### Configure Auth0
112
42
 
113
- On your template, provide a button that will allow the user to log in to the application. Use the `isAuthenticated$` observable to check that the user is not already authenticated:
43
+ Create a **Single Page Application** in the [Auth0 Dashboard](https://manage.auth0.com/#/applications).
114
44
 
115
- ```html
116
- <button
117
- *ngIf="(auth.isAuthenticated$ | async) === false"
118
- (click)="loginWithRedirect()"
45
+ > **If you're using an existing application**, verify that you have configured the following settings in your Single Page Application:
119
46
  >
120
- Log in
121
- </button>
122
- ```
123
-
124
- ### Add logout to your application
125
-
126
- Add a `logout` method to your component and call the SDK's `logout` method:
127
-
128
- ```js
129
- logout(): void {
130
- // Call this to log the user out of the application
131
- this.auth.logout({ returnTo: window.location.origin });
132
- }
133
- ```
134
-
135
- Then on your component's template, add a button that will log the user out of the application. Use the `isAuthenticated$` observable to check that the user has already been authenticated:
136
-
137
- ```html
138
- <button *ngIf="auth.isAuthenticated$ | async" (click)="logout()">
139
- Log out
140
- </button>
141
- ```
142
-
143
- ### Display the user profile
144
-
145
- Access the `user$` observable on the `AuthService` instance to retrieve the user profile. This observable already heeds the `isAuthenticated$` observable, so you do not need to check if the user is authenticated before using it:
146
-
147
- ```html
148
- <ul *ngIf="auth.user$ | async as user">
149
- <li>{{ user.name }}</li>
150
- <li>{{ user.email }}</li>
151
- </ul>
152
- ```
153
-
154
- ### Access ID token claims
47
+ > - Click on the "Settings" tab of your application's page.
48
+ > - Ensure that "Token Endpoint Authentication Method" under "Application Properties" is set to "None"
49
+ > - Scroll down and click on the "Show Advanced Settings" link.
50
+ > - Under "Advanced Settings", click on the "OAuth" tab.
51
+ > - Ensure that "JsonWebToken Signature Algorithm" is set to `RS256` and that "OIDC Conformant" is enabled.
155
52
 
156
- Access the `idTokenClaims$` observable on the `AuthService` instance to retrieve the ID token claims. Like the `user$` observable, this observable already heeds the `isAuthenticated$` observable, so you do not need to check if the user is authenticated before using it:
53
+ Next, configure the following URLs for your application under the "Application URIs" section of the "Settings" page:
157
54
 
158
- ```js
159
- authService.idTokenClaims$.subscribe((claims) => console.log(claims));
160
- ```
161
-
162
- ### Handle errors
55
+ - **Allowed Callback URLs**: `http://localhost:4200`
56
+ - **Allowed Logout URLs**: `http://localhost:4200`
57
+ - **Allowed Web Origins**: `http://localhost:4200`
163
58
 
164
- Errors in the login flow can be captured by subscribing to the `error$` observable:
59
+ > These URLs should reflect the origins that your application is running on. **Allowed Callback URLs** may also include a path, depending on where you're handling the callback.
165
60
 
166
- ```js
167
- authService.error$.subscribe((error) => console.log(error));
168
- ```
61
+ Take note of the **Client ID** and **Domain** values under the "Basic Information" section. You'll need these values in the next step.
169
62
 
170
- ### Protect a route
63
+ ### Configure the SDK
171
64
 
172
- To ensure that a route can only be visited by authenticated users, add the built-in `AuthGuard` type to the `canActivate` property on the route you wish to protect.
65
+ #### Static configuration
173
66
 
174
- If an unauthenticated user tries to access this route, they will first be redirected to Auth0 to log in before returning to the URL they tried to get to before login:
67
+ Install the SDK into your application by importing `AuthModule.forRoot()` and configuring with your Auth0 domain and client id:
175
68
 
176
- ```js
69
+ ```ts
177
70
  import { NgModule } from '@angular/core';
178
- import { Routes, RouterModule } from '@angular/router';
179
- import { HomeComponent } from './unprotected/unprotected.component';
180
- import { ProtectedComponent } from './protected/protected.component';
181
-
182
- // Import the authentication guard
183
- import { AuthGuard } from '@auth0/auth0-angular';
184
-
185
- const routes: Routes = [
186
- {
187
- path: 'protected',
188
- component: ProtectedComponent,
189
-
190
- // Protect a route by registering the auth guard in the `canActivate` hook
191
- canActivate: [AuthGuard],
192
- },
193
- {
194
- path: '',
195
- component: HomeComponent,
196
- pathMatch: 'full',
197
- },
198
- ];
199
-
200
- @NgModule({
201
- imports: [RouterModule.forRoot(routes)],
202
- exports: [RouterModule],
203
- })
204
- export class AppRoutingModule {}
205
- ```
206
-
207
- ### Call an API
208
-
209
- The SDK provides an `HttpInterceptor` that automatically attaches access tokens to outgoing requests when using the built-in `HttpClient`. However, you must provide configuration that tells the interceptor which requests to attach access tokens to.
210
-
211
- #### Specify the Audience
212
- In order for Auth0 to be able to issue tokens for a specific API, we need to configure the Audience to inform Auth0 about the API in question.
213
- Set the `audience`, when calling `AuthModule.forRoot()`, to the **API Identifier** of the API from within your Auth0 dashboard.
214
-
215
- ```js
216
- import { BrowserModule } from '@angular/platform-browser';
217
- import { NgModule } from '@angular/core';
218
- import { AppComponent } from './app.component';
219
-
220
- // Import the module from the SDK
221
71
  import { AuthModule } from '@auth0/auth0-angular';
222
72
 
223
73
  @NgModule({
224
- declarations: [AppComponent],
74
+ // ...
225
75
  imports: [
226
- BrowserModule,
227
-
228
- // Import the module into the application, with configuration
229
76
  AuthModule.forRoot({
230
77
  domain: 'YOUR_AUTH0_DOMAIN',
231
78
  clientId: 'YOUR_AUTH0_CLIENT_ID',
232
- audience: 'YOUR_AUTH0_API_IDENTIFIER',
233
79
  }),
234
80
  ],
235
-
236
- bootstrap: [AppComponent],
81
+ // ...
237
82
  })
238
83
  export class AppModule {}
239
84
  ```
240
85
 
241
- #### Register AuthHttpInterceptor
242
-
243
- First, register the interceptor with your application module, along with the `HttpClientModule`.
244
-
245
- **Note:** We do not do this automatically for you as we want you to be explicit about including this interceptor. Also, you may want to chain this interceptor with others, making it hard for us to place it accurately.
246
-
247
- ```js
248
- // Import the interceptor module and the Angular types you'll need
249
- import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
250
- import { AuthHttpInterceptor } from '@auth0/auth0-angular';
251
-
252
- // Register the interceptor with your app module in the `providers` array
253
- @NgModule({
254
- declarations: [],
255
- imports: [
256
- BrowserModule,
257
- HttpClientModule, // Register this so that you can make API calls using HttpClient
258
- AppRoutingModule,
259
- AuthModule.forRoot(...),
260
- ],
261
- providers: [
262
- { provide: HTTP_INTERCEPTORS, useClass: AuthHttpInterceptor, multi: true },
263
- ],
264
- bootstrap: [AppComponent],
265
- })
266
- ```
267
-
268
- #### Configure AuthHttpInterceptor to attach access tokens
269
-
270
- Next, tell the SDK which requests to attach access tokens to in the SDK configuration. These are matched on the URL by using a string, a regex, or more complex object that also allows you to specify the configuration for fetching tokens by setting the `tokenOptions` property.
271
-
272
- If an HTTP call is made using `HttpClient` and there is no match in this configuration for that URL, then the interceptor will simply be bypassed and the call will be executed without a token attached in the `Authorization` header.
273
-
274
- **Note:** We do this to help prevent tokens being unintentionally attached to requests to the wrong recipient, which is a serious security issue. Those recipients could then use that token to call the API as if it were your application.
275
-
276
- In the event that requests should be made available for both anonymous and authenticated users, the `allowAnonymous` property can be set to `true`. When omitted, or set to `false`, requests that match the configuration, will not be executed when there is no access token available.
277
-
278
- Here are some examples:
279
-
280
- ```js
281
- import { HttpMethod } from '@auth0/auth0-angular';
282
-
283
- // Modify your existing SDK configuration to include the httpInterceptor config
284
- AuthModule.forRoot({
285
- ...
286
- // The AuthHttpInterceptor configuration
287
- httpInterceptor: {
288
- allowedList: [
289
- // Attach access tokens to any calls to '/api' (exact match)
290
- '/api',
291
-
292
- // Attach access tokens to any calls that start with '/api/'
293
- '/api/*',
294
-
295
- // Match anything starting with /api/products, but also allow for anonymous users.
296
- {
297
- uri: '/api/products/*',
298
- allowAnonymous: true,
299
- },
300
-
301
- // Match anything starting with /api/accounts, but also specify the audience and scope the attached
302
- // access token must have
303
- {
304
- uri: '/api/accounts/*',
305
- tokenOptions: {
306
- audience: 'http://my-api/',
307
- scope: 'read:accounts',
308
- },
309
- },
310
-
311
- // Matching on HTTP method
312
- {
313
- uri: '/api/orders',
314
- httpMethod: HttpMethod.Post,
315
- tokenOptions: {
316
- audience: 'http://my-api/',
317
- scope: 'write:orders',
318
- },
319
- },
320
-
321
- // Using an absolute URI
322
- {
323
- uri: 'https://your-domain.auth0.com/api/v2/users',
324
- tokenOptions: {
325
- audience: 'https://your-domain.com/api/v2/',
326
- scope: 'read:users',
327
- },
328
- },
329
- ],
330
- },
331
- });
332
- ```
333
-
334
- > Under the hood, `tokenOptions` is passed as-is to [the `getTokenSilently` method](https://auth0.github.io/auth0-spa-js/classes/auth0client.html#gettokensilently) on the underlying SDK, so all the same options apply here.
335
-
336
- **Uri Matching**
337
-
338
- If you need more fine-grained control over the URI matching, you can provide a callback function to the `uriMatcher` property that takes a single `uri` argument (being [`HttpRequest.url`](https://angular.io/api/common/http/HttpRequest#url)) and returns a boolean. If this function returns true, then an access token is attached to the request in the ["Authorization" header](https://tools.ietf.org/html/draft-ietf-oauth-v2-bearer-20#section-2.1). If it returns false, the request proceeds without the access token attached.
339
-
340
- ```
341
- AuthModule.forRoot({
342
- ...
343
- httpInterceptor: {
344
- allowedList: [
345
- {
346
- uriMatcher: (uri) => uri.indexOf('/api/orders') > -1,
347
- httpMethod: HttpMethod.Post,
348
- tokenOptions: {
349
- audience: 'http://my-api/',
350
- scope: 'write:orders',
351
- },
352
- },
353
- ],
354
- },
355
- });
356
- ```
357
-
358
- You might want to do this in scenarios where you need the token on multiple endpoints, but want to exclude it from only a few other endpoints. Instead of explicitly listing all endpoints that do need a token, a uriMatcher can be used to include all but the few endpoints that do not need a token attached to its requests.
359
-
360
- #### Use HttpClient to make an API call
361
-
362
- Finally, make your API call using the `HttpClient`. Access tokens are then attached automatically in the `Authorization` header:
363
-
364
- ```js
365
- export class MyComponent {
366
- constructor(private http: HttpClient) {}
367
-
368
- callApi(): void {
369
- this.http.get('/api').subscribe(result => console.log(result));
370
- }
371
- }
372
- ```
373
-
374
- #### Handling errors
375
-
376
- Whenever the SDK fails to retrieve an Access Token, either as part of the above interceptor or when manually calling `AuthService.getAccessTokenSilently` and `AuthService.getAccessTokenWithPopup`, it will emit the corresponding error in the `AuthService.error$` observable.
377
-
378
- If you want to interact to these errors, subscribe to the `error$` observable and act accordingly.
379
-
380
- ```
381
- ngOnInit() {
382
- this.authService.error$.subscribe(error => {
383
- // Handle Error here
384
- });
385
- }
386
- ```
387
-
388
- A common reason you might want to handle the above errors, emitted by the `error$` observable, is to re-login the user when the SDK throws a `login_required` error.
389
-
390
- ```
391
- ngOnInit() {
392
- this.authService.error$.pipe(
393
- filter((e) => e instanceof GenericError && e.error === 'login_required'),
394
- mergeMap(() => this.authService.loginWithRedirect())
395
- ).subscribe();
396
- }
397
- ```
398
-
399
- ### Dynamic Configuration
86
+ #### Dynamic configuration
400
87
 
401
88
  Instead of using `AuthModule.forRoot` to specify auth configuration, you can provide a factory function using `APP_INITIALIZER` to load your config from an external source before the auth module is loaded, and provide your configuration using `AuthClientConfig.set`.
402
89
 
@@ -405,8 +92,6 @@ The configuration will only be used initially when the SDK is instantiated. Any
405
92
  > :information_source: Any request made through an instance of `HttpClient` that got instantiated by Angular, will use all of the configured interceptors, including our `AuthHttpInterceptor`. Because the `AuthHttpInterceptor` requires the existence of configuration settings, the request for retrieving those dynamic configuration settings should ensure it's not using any of those interceptors. In Angular, this can be done by manually instantiating `HttpClient` using an injected `HttpBackend` instance.
406
93
 
407
94
  ```js
408
- // app.module.ts
409
- // ---------------------------
410
95
  import { AuthModule, AuthClientConfig } from '@auth0/auth0-angular';
411
96
 
412
97
  // Provide an initializer function that returns a Promise
@@ -418,88 +103,33 @@ function configInitializer(
418
103
  new HttpClient(handler)
419
104
  .get('/config')
420
105
  .toPromise()
421
- .then((loadedConfig: any) => config.set(loadedConfig)); // Set the config that was loaded asynchronously here
106
+ // Set the config that was loaded asynchronously here
107
+ .then((loadedConfig: any) => config.set(loadedConfig));
422
108
  }
423
109
 
424
- // Provide APP_INITIALIZER with this function. Note that there is no config passed to AuthModule.forRoot
425
- imports: [
426
- // other imports..
427
-
428
- HttpClientModule,
429
- AuthModule.forRoot(), //<- don't pass any config here
430
- ],
431
- providers: [
432
- {
433
- provide: APP_INITIALIZER,
434
- useFactory: configInitializer, // <- pass your initializer function here
435
- deps: [HttpBackend, AuthClientConfig],
436
- multi: true,
437
- },
438
- ],
439
- ```
440
-
441
- ### Using multiple OAuth providers
442
-
443
- If your application uses multiple OAuth providers, you may need to use multiple callback paths as well, one for each OAuth provider.
444
- To ensure the SDK does not process the callback for any provider other than Auth0, configure the AuthModule by setting the `skipRedirectCallback` property as follows:
445
-
446
- ```js
447
- AuthModule.forRoot({
448
- skipRedirectCallback: window.location.pathname === '/other-callback',
449
- });
450
- ```
451
-
452
- **Note**: In the above example, `/other-callback` is an existing route that will be called by any other OAuth provider with a `code` (or `error` in case something went wrong) and `state`.
453
-
454
- ### Organizations
455
-
456
- [Organizations](https://auth0.com/docs/organizations) is a set of features that provide better support for developers who build and maintain SaaS and Business-to-Business (B2B) applications.
457
-
458
- Using Organizations, you can:
459
-
460
- - Represent teams, business customers, partner companies, or any logical grouping of users that should have different ways of accessing your applications, as organizations.
461
-
462
- - Manage their membership in a variety of ways, including user invitation.
463
-
464
- - Configure branded, federated login flows for each organization.
465
-
466
- - Implement role-based access control, such that users can have different roles when authenticating in the context of different organizations.
467
-
468
- - Build administration capabilities into your products, using Organizations APIs, so that those businesses can manage their own organizations.
469
-
470
- Note that Organizations is currently only available to customers on our Enterprise and Startup subscription plans.
471
-
472
- #### Log in to an organization
473
-
474
- Log in to an organization by specifying the `organization` parameter importing the `AuthModule`:
475
-
476
- ```
477
- AuthModule.forRoot({
478
- domain: 'YOUR_AUTH0_DOMAIN',
479
- clientId: 'YOUR_AUTH0_CLIENT_ID',
480
- organization: 'YOUR_ORGANIZATION_ID'
481
- }),
482
- ```
483
-
484
- You can also specify the organization when logging in:
485
-
486
- ```
487
- // Using a redirect
488
- this.auth.loginWithRedirect({
489
- organization: 'YOUR_ORGANIZATION_ID'
490
- });
491
-
492
- // Using a popup window
493
- this.auth.loginWithPopup({
494
- organization: 'YOUR_ORGANIZATION_ID'
495
- });
110
+ export class AppModule {
111
+ // ...
112
+ imports: [
113
+ HttpClientModule,
114
+ AuthModule.forRoot(), // <- don't pass any config here
115
+ ],
116
+ providers: [
117
+ {
118
+ provide: APP_INITIALIZER,
119
+ useFactory: configInitializer, // <- pass your initializer function here
120
+ deps: [HttpBackend, AuthClientConfig],
121
+ multi: true,
122
+ },
123
+ ],
124
+ // ...
125
+ }
496
126
  ```
497
127
 
498
- #### Accept user invitations
128
+ ### Add login to your application
499
129
 
500
- Accept a user invitation through the SDK by creating a route within your application that can handle the user invitation URL, and log the user in by passing the `organization` and `invitation` parameters from this URL. You can either use `loginWithRedirect` or `loginWithPopup` as needed.
130
+ To log the user into the application, inject the `AuthService` and call its `loginWithRedirect` method.
501
131
 
502
- ```js
132
+ ```ts
503
133
  import { Component } from '@angular/core';
504
134
  import { AuthService } from '@auth0/auth0-angular';
505
135
 
@@ -509,88 +139,50 @@ import { AuthService } from '@auth0/auth0-angular';
509
139
  styleUrls: ['./app.component.css'],
510
140
  })
511
141
  export class AppComponent {
512
- constructor(public auth: AuthService, private activatedRoute: ActivatedRoute) {}
513
-
514
- loginWithRedirect(): void {
515
- const { organization, invitation } = this.activatedRoute.snapshot.params;
142
+ constructor(public auth: AuthService) {}
516
143
 
517
- this.auth.loginWithRedirect({
518
- organization,
519
- invitation
520
- });
144
+ loginWithRedirect() {
145
+ this.auth.loginWithRedirect();
521
146
  }
522
- }
523
147
  ```
524
148
 
525
- ## Angular Universal
526
-
527
- This library makes use of the `window` object in a couple of places during initialization, as well as `sessionStorage` in the underlying Auth0 SPA SDK, and thus [will have problems](https://github.com/angular/universal/blob/master/docs/gotchas.md#window-is-not-defined) when being used in an Angular Universal project. The recommendation currently is to only import this library into a module that is to be used in the browser, and omit it from any module that is to participate in a server-side environment.
528
-
529
- See [Guards, and creating separate modules](https://github.com/angular/universal/blob/master/docs/gotchas.md#strategy-2-guards) in the Angular Universal "Gotchas" document.
530
-
531
- ## Development
149
+ By default the application will ask Auth0 to redirect back to the root URL of your application after authentication. This can be configured by setting the [redirectUri](https://auth0.github.io/auth0-angular/interfaces/auth_config.authconfig.html#redirecturi) option.
532
150
 
533
- ### Build
151
+ For more code samples on how to integrate the **auth0-angular** SDK in your **Angular** application, have a look at our [examples](https://github.com/auth0/auth0-angular/tree/master/EXAMPLES.md).
534
152
 
535
- Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
153
+ ## API reference
536
154
 
537
- ### Running unit tests
155
+ Explore public API's available in auth0-angular.
538
156
 
539
- Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
540
-
541
- ### Running end-to-end tests
542
-
543
- The end-to-end tests are executed using [Cypress](https://www.cypress.io/) against the built-in playground app.
544
-
545
- The E2E tests require that the user password be specified as an environment variable. This is already set up in the CI environment, but locally you can do:
546
-
547
- ```
548
- CYPRESS_INTEGRATION_PASSWORD=<password> ng e2e
549
- ```
157
+ - [AuthService](https://auth0.github.io/auth0-angular/classes/auth_service.authservice.html) - service used to interact with the SDK.
158
+ - [AuthConfig](https://auth0.github.io/auth0-angular/interfaces/auth_config.authconfig.html) - used to configure the SDK.
550
159
 
551
- ### Running the playground app
160
+ ## Feedback
552
161
 
553
- The workspace includes a playground application that can be used to test out features of the SDK. Run this using `ng serve playground` and browse to http://localhost:4200.
554
-
555
- #### Running an express server
556
-
557
- An express server can be started by running `npm run server:api`, which can be used to make testing Http Interceptors easier.
558
- The express server exposes a single endpoint at `http://localhost:3001/api/external` that needs to be called with an `Authorization` header containing a token for the corresponding `domain` and `audience`, configurable in [`api-server.js`](api-server.js).
559
-
560
- The playground application is preconfigured to call the above endpoint when clicking the `Call external API` button.
561
-
562
- ## Further help
563
-
564
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
565
-
566
- ## Contributing
162
+ ### Contributing
567
163
 
568
164
  We appreciate feedback and contribution to this repo! Before you get started, please see the following:
569
165
 
570
166
  - [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
571
167
  - [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
572
168
 
573
- ## Support + Feedback
169
+ ### Raise an issue
574
170
 
575
- For support or to provide feedback, please [raise an issue on our issue tracker](https://github.com/auth0/auth0-angular/issues).
171
+ To provide feedback or report a bug, please [raise an issue on our issue tracker](https://github.com/auth0/auth0-angular/issues).
576
172
 
577
- ## Vulnerability Reporting
173
+ ### Vulnerability Reporting
578
174
 
579
175
  Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/responsible-disclosure-policy) details the procedure for disclosing security issues.
580
176
 
581
- ## What is Auth0?
582
-
583
- Auth0 helps you to easily:
584
-
585
- - Implement authentication with multiple identity providers, including social (e.g., Google, Facebook, Microsoft, LinkedIn, GitHub, Twitter, etc), or enterprise (e.g., Windows Azure AD, Google Apps, Active Directory, ADFS, SAML, etc.)
586
- - Log in users with username/password databases, passwordless, or multi-factor authentication
587
- - Link multiple user accounts together
588
- - Generate signed JSON Web Tokens to authorize your API calls and flow the user identity securely
589
- - Access demographics and analytics detailing how, when, and where users are logging in
590
- - Enrich user profiles from other data sources using customizable JavaScript rules
591
-
592
- [Why Auth0?](https://auth0.com/why-auth0)
593
-
594
- ## License
595
-
596
- This project is licensed under the MIT license. See the [LICENSE](https://github.com/auth0/auth0-angular/blob/master/LICENSE) file for more info.
177
+ ---
178
+
179
+ <p align="center">
180
+ <picture>
181
+ <source media="(prefers-color-scheme: light)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
182
+ <source media="(prefers-color-scheme: dark)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png" width="150">
183
+ <img alt="Auth0 Logo" src="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
184
+ </picture>
185
+ </p>
186
+ <p align="center">Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout <a href="https://auth0.com/why-auth0">Why Auth0?</a></p>
187
+ <p align="center">
188
+ This project is licensed under the MIT license. See the <a href="https://github.com/auth0/auth0-angular/tree/master/LICENSE"> LICENSE</a> file for more info.</p>