@authing/guard-angular
TypeScript icon, indicating that this package has built-in type declarations

5.3.8 • Public • Published

English | 简体中文


Guard is a portable authentication component provided by authing. You can embed it in any application to handle complex user authentication processes in one stop.

Prepare your Angular project and follow the guide to connect Guard to your Angular project!

Install

npm install --save @authing/guard-angular

Initialize

Key Type Default Requires
appId String - Y
host String - N
redirectUri String - N
mode normal / modal normal N
defaultScene GuardModuleType login N
tenantId String - N
lang zh-CN / en-US zh-CN N
isSSO Boolean true N
config Partial - N
// angular.json
{
  "projects": {
    "architect": {
      "build": {
        "styles": [
          "node_modules/@authing/guard-angular/dist/guard.min.css"
        ]
      }
    }
  }
}
// app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

import { GuardModule } from '@authing/guard-angular'

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    GuardModule.forRoot({
      appId: '62e22721c889dd44bad1dda2',
      host: 'https://guard-test-2022.authing.cn',
      redirectUri: 'http://localhost:3000/callback'
    })
  ],
  providers: [],
  bootstrap: [AppComponent]
})

export class AppModule { }
// use Guard APIs in Components
import { Component } from '@angular/core'

import { GuardService } from '@authing/guard-angular'

@Component({
  selector: 'login-container',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.css']
})
export class LoginComponent {
  constructor (
    private guard: GuardService
  ) {}

  userInfo = ''

  ngOnInit () {
   console.log(this.guard.client)
  }
}

Guard for Angular provides three login modes

Embed mode

Render Guard component

import { Component } from '@angular/core'

import { GuardService } from '@authing/guard-angular'

@Component({
  selector: 'login-container',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.css']
})
export class LoginComponent {
  constructor (
    private guard: GuardService
  ) {}

  userInfo = ''

  ngOnInit () {
    this.guard.client.start('#guard-root')
  }
}

modal mode

When the parameter 'mode' of Guard instantiation is' modal ', the modal mode is started, and the following API can be used to display and hide the guard.

this.guard.client.show()
this.guard.client.hide()

Redirect mode

Login by code, redirect to login page

this.guard.client.startWithRedirect()

Auto handle redirect callback

this.guard.client.handleRedirectCallback()

Logout

this.guard.client.logout()

Regist events

this.guard.client.on('load', e => {
  console.log(e)
})

this.guard.client.on('login', userInfo => {
  console.log(userInfo)
})

// ......

Integrate authing js sdk instance

Guard integrated AuthenticationClient, so you can access all apis of AuthenticationClient, etc:

this.guard.client.getAuthClient().then(authClient => {
  authClient.registerByEmail()
  authClient.validateToken()
  // .......
})
// ....

Refer to Authentication SDK

Documentation

To check out live examples and docs, visit docs

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
5.3.5-fehorizon.102alpha
5.3.81latest

Version History

VersionDownloads (Last 7 Days)Published
5.3.5-fehorizon.102
5.3.5-fehorizon.71
5.3.81
5.3.5-fehorizon.61
5.3.8-alpha.01
5.3.5-fehorizon.51
5.3.71
5.3.5-fehorizon.41
5.3.5-fehorizon.31
5.3.62
5.3.5-fehorizon.11
5.3.51
5.3.5-alpha.31
5.3.5-alpha.22
5.3.5-alpha.12
5.3.41
5.3.32
5.3.3-alpha.42
5.3.3-alpha.31
5.3.3-alpha.22
5.3.3-alpha.11
5.3.3-alpha.02
5.3.23
5.3.2-alpha.12
5.3.2-alpha.02
5.3.12
5.3.1-alpha.01
5.3.02
5.3.0-alpha.82
5.3.0-alpha.71
5.3.0-alpha.62
5.3.0-alpha.52
5.2.41
5.2.4-alpha.12
5.2.4-alpha.02
5.2.31
5.2.3-alpha.01
5.2.22
5.2.2-alpha.01
5.2.12
5.2.1-alpha.02
5.3.0-alpha.41
5.3.0-alpha.32
5.3.0-alpha.21
5.3.0-alpha.02
6.0.0-alpha.182
6.0.0-alpha.171
5.2.01
5.2.0-alpha.01
6.0.0-alpha.161
6.0.0-alpha.152
6.0.0-alpha.142
6.0.0-alpha.131
5.1.112
5.1.102
5.1.91
5.1.9-alpha.22
5.1.9-alpha.11
5.1.9-alpha.01
5.1.81
6.0.0-alpha.121
6.0.0-alpha.111
6.0.0-alpha.102
6.0.0-alpha.92
6.0.0-alpha.81
6.0.0-alpha.71
6.0.0-alpha.62
6.0.0-alpha.52
6.0.0-alpha.41
6.0.0-alpha.32
6.0.0-alpha.22
6.0.0-alpha.11
6.0.0-alpha.02
5.1.71
5.1.7-alpha.32
5.1.7-alpha.21
5.1.7-alpha.11
5.1.7-alpha.01
5.1.61
5.1.6-alpha.21
5.1.6-alpha.11
5.1.6-alpha.01
5.1.51
5.1.5-alpha.11
5.1.5-alpha.02
5.1.42
5.1.4-alpha.22
5.1.4-alpha.11
5.1.32
5.1.3-alpha.262
5.1.3-alpha.251
5.1.3-alpha.242
5.1.3-alpha.231
5.1.3-alpha.221
5.1.3-alpha.212
5.1.3-alpha.201
5.1.3-alpha.191
5.1.4-alpha.01
5.1.3-alpha.181
5.1.3-alpha.172
5.1.3-alpha.161
5.1.3-alpha.151
5.1.3-alpha.142
5.1.3-alpha.131
5.1.3-alpha.121
5.1.3-alpha.111
5.1.3-alpha.101
5.1.3-alpha.92
5.1.3-alpha.81
5.1.3-alpha.71
5.1.3-alpha.61
5.1.3-alpha.51
5.1.3-alpha.41
5.1.3-alpha.01
5.1.22
5.1.2-alpha.02
5.1.11
5.1.1-alpha.12
5.1.1-alpha.02
5.1.01
5.1.0-alpha.01
5.0.8-alpha.152
5.0.8-alpha.141
5.0.8-alpha.131
5.0.8-alpha.122
5.0.8-alpha.111
5.0.8-alpha.101
5.0.8-alpha.92
5.0.8-alpha.82
5.0.8-alpha.71
5.0.8-alpha.62
5.0.8-alpha.52
5.0.8-alpha.41
5.0.8-alpha.32
5.0.8-alpha.21
5.0.8-alpha.11
5.0.8-alpha.01
5.0.72
5.0.7-alpha.02
5.0.61
5.0.6-alpha.01
5.0.51
5.0.5-alpha.311
5.0.5-alpha.301
5.0.5-alpha.291
5.0.5-alpha.282
5.0.5-alpha.271
5.0.5-alpha.261
5.0.5-alpha.251
5.0.5-alpha.241
5.0.5-alpha.231
5.0.5-alpha.221
5.0.5-alpha.212
5.0.5-alpha.201
5.0.5-alpha.191
5.0.5-alpha.181
5.0.5-alpha.171
5.0.5-alpha.162
5.0.5-alpha.152
5.0.5-alpha.142
5.0.5-alpha.131
5.0.5-alpha.121
5.0.5-alpha.111
5.0.5-alpha.101
5.0.5-alpha.91
5.0.5-alpha.81
5.0.5-alpha.71
5.0.5-alpha.61
5.0.5-alpha.52
5.0.5-alpha.41
5.0.5-alpha.32
5.0.5-alpha.22
5.0.5-alpha.12
5.0.42
5.0.4-alpha.52
5.0.4-alpha.42
5.0.4-alpha.32
5.0.4-alpha.02
5.0.31
5.0.22
5.0.12
5.0.02
5.0.0-alpha.191
5.0.0-alpha.183
5.0.0-alpha.171
5.0.0-alpha.161
5.0.0-alpha.152
5.0.0-alpha.142
5.0.0-alpha.131
5.0.0-alpha.122
5.0.0-alpha.112
5.0.0-alpha.101
5.0.0-alpha.92
5.0.0-alpha.83
5.0.0-alpha.71
5.0.0-alpha.62

Package Sidebar

Install

npm i @authing/guard-angular

Weekly Downloads

284

Version

5.3.8

License

MIT

Unpacked Size

551 kB

Total Files

23

Last publish

Collaborators

  • authing