6.1.0 • Published 7 months ago

@dangl/angular-dangl-identity-client v6.1.0

Weekly downloads
16
License
-
Repository
-
Last release
7 months ago

Dangl.Identity Client Libraries

Build Status

Changelog
Online Documentation

Dangl.Identity is an OpenID / OAuth2 capable server that offers single sign on functionalities. It's primary is available at https://identity.dangl-it.com with a fallback at https://identity.dangl-it.de.
It works with all OpenID Connect compatible clients and it's configuration is available here.
The preview is available at https://identity-dev.dangl-it.com.

The Dangl.Identity.Client libraries offer specialised classes and utilities that make integrating and connecting with Dangl.Identity easy.

Default Configuration

By default, the identity provider is expected to be reachable at https://identity.dangl-it.com.

Dangl.Identity.Client

This project includes the DanglIdentityLoginHandler that offers JWT / OAuth2 login and refresh functionalities for clients that have the ResourceOwnerPasswordGrant enabled. The DanglIdentityClientCredentialsLoginHandler can be used with clients that have the ClientCredentials grant enabled, for example in server-side applications.

Both login handlers require an instance of HttpClient to be injected at creation. It is advised that the HttpClientFactory from the Microsoft.Extensions.Http package is used to efficiently manage the lifetime of HttpClient instances.

Angular Client

Web applications that use the integrated Dangl.Identity JWT endpoints from the Dangl.Identity.Client.MVC package can use the @dangl/angular-dangl-identity-client npm package.

This package offers a generated client for the Dangl.Identity JWT endpoints and manages local storage of JWT tokens. The client assumes that the endpoint is available on the current host, otherwise it uses an injection parameter:

@Optional() @Inject(DANGL_IDENTITY_CLIENT_API_BASE_URL) baseUrl?: string

The Angular client works by adding an Http interceptor that attaches the JWT token to all requests. Additionally, it provides the following services:

AuthenticationService

The AuthenticationService offers methods to login and logout. This only works when the backend is configured to accept the ResourceOwnerPasswordGrant grant type.

AuthenticationMessenger

The AuthenticationMessenger offers an observable that can be used to watch for changes in the authentication state. It will provide additional information contained in the JWT, like the user name and roles.

Additionally, if cookie authentication is used and the frontend does not have direct access to JWTs, then you can call AuthenticationMessenger.refreshUserInfoFromServer() to let the service fetch the current user info from the backend and raise the internal observables.

JwtTokenService

The JwtTokenService offers methods to retrieve the current JWT token, to check if it is expired and to update it. It will internally handle refreshing the token as well, if there is a refresh token present.

Install Dependencies

The package requires a peer dependency of @auth0/angular-jwt which must be manually installed in the consuming project.

Reference Module

Just import the DanglIdentityModule in your app.

import { AppComponent } from './app.component';
import { DanglIdentityModule } from '@dangl/angular-dangl-identity-client';

@NgModule({
  imports: [
    DanglIdentityModule
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

Validate Requests for Including JWT Authorization Header

By default, the provided JwtInterceptorService will attach JWT bearer tokens to all requests, if tokens are present. If you want to control whether or not you want to include them, you need to provide the following optional dependency:

@Optional()
@Inject(DANGL_IDENTITY_REQUEST_VALIDATOR)
private requestValidator: IDanglIdentityRequestValidator

In the model, you can provide it like this:

providers: [
  {
    provide: DANGL_IDENTITY_REQUEST_VALIDATOR,
    useClass: MyCustomRequestValidator,
  }
]

Login / Logout

Here's an example login functionality:

import { AuthenticationService,
  AuthenticationMessenger } from '@dangl/angular-dangl-identity-client';

this.isAuthenticatedSubscription = this.authenticationMessenger
      .isAuthenticated
      .subscribe(ia => this.isAuthenticated = ia);

login() {
    this.requestEnRoute = true;

    this.authenticationService
      .loginWithToken(this.credentials.identifier, this.credentials.password)
      .subscribe(r => {
        this.requestEnRoute = false;
        if (r) {
          this.showLoginError = false;
          this.errorCount = 0;
          this.router.navigateByUrl('/');
        } else {
          this.showLoginError = true;
          this.errorCount++;
        }
      });
  }

AuthenticationMessenger

The AuthenticationMessenger class can be used to watch for changes in the authentication. It will automatically try to refresh the token if a refresh token is present and the current token is expired on load.

Assembly Strong Naming & Usage in Signed Applications

This module produces strong named assemblies when compiled. When consumers of this package require strongly named assemblies, for example when they themselves are signed, the outputs should work as-is. The key file to create the strong name is adjacent to the csproj file in the root of the source project. Please note that this does not increase security or provide tamper-proof binaries, as the key is available in the source code per Microsoft guidelines

6.1.0

7 months ago

6.0.2-beta0007

8 months ago

6.0.2-beta0009

8 months ago

6.0.0-beta0017

10 months ago

6.0.1-beta0001

10 months ago

6.0.1

10 months ago

6.0.2

8 months ago

6.1.0-beta0008

7 months ago

6.1.0-beta0009

7 months ago

6.1.0-beta0006

7 months ago

6.1.0-beta0007

7 months ago

6.1.0-beta0004

7 months ago

6.1.0-beta0005

7 months ago

6.1.0-beta0011

7 months ago

6.1.0-beta0012

7 months ago

6.1.0-beta0010

7 months ago

5.0.2-beta0012

11 months ago

5.0.2-beta0010

11 months ago

5.0.1-beta0001

1 year ago

5.0.1-beta0003

1 year ago

5.0.1

1 year ago

5.0.0

1 year ago

5.0.0-beta0011

1 year ago

5.0.0-beta0009

1 year ago

4.1.3-beta0008

2 years ago

4.1.3-beta0007

2 years ago

4.1.3

2 years ago

4.1.2-beta0001

2 years ago

4.1.1-beta0010

2 years ago

4.1.1-beta0011

2 years ago

4.1.3-beta0001

2 years ago

4.1.1-beta0008

2 years ago

4.1.2

2 years ago

4.1.1

2 years ago

4.1.0-beta0002

2 years ago

4.1.0

2 years ago

4.0.1

2 years ago

4.0.1-beta0003

2 years ago

4.0.1-beta0001

2 years ago

4.0.1-beta0004

2 years ago

4.0.0

3 years ago

4.0.0-beta0015

3 years ago

4.0.0-beta0013

3 years ago

4.0.0-beta0012

3 years ago

3.4.0

3 years ago

4.0.0-beta0011

3 years ago

3.4.0-beta0025

3 years ago

3.4.0-beta0024

3 years ago

3.4.0-beta0019

3 years ago

3.4.0-beta0016

3 years ago

3.4.0-beta0015

3 years ago

3.4.0-beta0017

3 years ago

1.4.0-beta0009

3 years ago

3.4.0-beta0003

3 years ago

3.3.1-beta0003

3 years ago

3.3.1

3 years ago

3.3.1-beta0001

3 years ago

3.3.0

3 years ago

3.3.0-beta0006

3 years ago

3.2.6-beta0003

3 years ago

3.2.6-beta0001

3 years ago

3.2.5

3 years ago

3.2.5-beta0005

3 years ago

3.2.5-beta0004

3 years ago

3.2.5-beta0001

4 years ago

3.2.4

4 years ago

3.2.4-beta0007

4 years ago

3.2.4-beta0006

4 years ago

3.2.3-beta0002

4 years ago

3.2.3

4 years ago

3.2.2

4 years ago

3.2.2-beta0002

4 years ago

3.2.1

4 years ago

3.2.1-beta0003

4 years ago

3.2.1-beta0001

4 years ago

3.2.0

4 years ago

3.2.0-beta0002

4 years ago

3.2.0-beta0001

4 years ago

3.1.0

4 years ago

3.1.0-beta0004

4 years ago

3.0.0

4 years ago

3.0.0-beta0032

4 years ago

3.0.0-beta0031

4 years ago

3.0.0-beta0030

4 years ago

3.0.0-beta0028

4 years ago

3.0.0-beta0026

4 years ago

2.6.1-beta0001

4 years ago

2.6.0

5 years ago

2.6.0-beta0003

5 years ago

2.5.2

5 years ago

2.5.2-beta0004

5 years ago

2.5.1

5 years ago

2.5.1-beta0001

5 years ago

2.5.0

5 years ago

2.5.0-beta0005

5 years ago

2.4.4-beta0002

5 years ago

2.4.3

5 years ago

2.4.3-beta0002

5 years ago

2.4.2

5 years ago

2.4.2-beta0012

5 years ago

2.4.2-beta0011

5 years ago

2.4.2-beta0008

5 years ago

2.4.2-beta0004

5 years ago

2.4.2-beta0003

5 years ago

2.4.2-beta0002

5 years ago

2.4.2-beta0001

5 years ago

2.4.1

5 years ago

2.4.1-beta0001

5 years ago

2.4.0

5 years ago

2.4.0-beta0007

5 years ago

2.3.1-beta0005

5 years ago

2.3.1-beta0003

5 years ago

2.3.1-beta0001

5 years ago

2.3.0

5 years ago

2.3.0-beta0021

5 years ago

2.3.0-beta0018

5 years ago

2.3.0-beta0019

5 years ago

2.3.0-beta0017

5 years ago

2.3.0-beta0016

5 years ago

2.3.0-beta0015

5 years ago

2.3.0-beta0013

5 years ago

2.3.0-beta0010

5 years ago

2.3.0-beta0009

5 years ago

2.2.2-beta0002

5 years ago

2.2.2-beta0001

5 years ago

2.2.1

5 years ago

2.2.1-beta0008

5 years ago

2.2.1-beta0005

5 years ago

2.2.0

5 years ago

2.2.0-beta0020

5 years ago

2.1.1-beta0019

5 years ago

2.1.1-beta0017

5 years ago

2.1.1-beta0014

5 years ago

2.1.1-beta0010

5 years ago

2.1.1-beta0009

5 years ago