How to use @nebular/auth - 10 common examples

To help you get started, we’ve selected a few @nebular/auth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github akveo / nebular / src / playground / without-layout / azure / azure-adb2c-auth-strategy.ts View on Github external
getValue(): string {
    return this.token.id_token;
  }
}

@Injectable()
export class AzureADB2CAuthStrategy extends NbOAuth2AuthStrategy {

  // we need this method for strategy setup
  static setup(options: NbOAuth2AuthStrategyOptions): [NbAuthStrategyClass, NbOAuth2AuthStrategyOptions] {
    return [AzureADB2CAuthStrategy, options];
  }

  protected redirectResultHandlers = {
    [NbOAuth2ResponseType.CODE]: () => {
      return of(this.route.snapshot.queryParams).pipe(
        switchMap((params: any) => {
          if (params.code) {
            return this.requestToken(params.code);
          }

          return of(
            new NbAuthResult(
              false,
              params,
              this.getOption('redirect.failure'),
              this.getOption('defaultErrors'),
              [],
            ));
        }),
      );
github akveo / nebular / src / framework / auth / services / interceptors / jwt-interceptor.spec.ts View on Github external
describe('jwt-interceptor', () => {

  // tslint:disable
  const validJWTValue = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJjZXJlbWEuZnIiLCJpYXQiOjE1MzIzNTA4MDAsImV4cCI6MjUzMjM1MDgwMCwic3ViIjoiQWxhaW4gQ0hBUkxFUyIsImFkbWluIjp0cnVlfQ.Rgkgb4KvxY2wp2niXIyLJNJeapFp9z3tCF-zK6Omc8c';
  const validJWTToken = new NbAuthJWTToken(validJWTValue, 'dummy');
  const expiredJWTToken = new NbAuthJWTToken('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzY290Y2guaW8iLCJleHAiOjEzMDA4MTkzODAsIm5hbWUiOiJDaHJpcyBTZXZpbGxlamEiLCJhZG1pbiI6dHJ1ZX0.03f329983b86f7d9a9f5fef85305880101d5e302afafa20154d094b229f75773','dummy');
  const authHeader = 'Bearer ' + validJWTValue;

  let authService: NbAuthService;
  let tokenService: NbTokenService;
  let dummyAuthStrategy: NbDummyAuthStrategy;

  let http: HttpClient;
  let httpMock: HttpTestingController;

  function filterInterceptorRequest(req: HttpRequest): boolean {
    return ['/filtered/url']
      .some(url => req.url.includes(url));
  }

  beforeEach(() => {
    TestBed.configureTestingModule({
github akveo / nebular / src / framework / auth / services / interceptors / jwt-interceptor.spec.ts View on Github external
describe('jwt-interceptor', () => {

  // tslint:disable
  const validJWTValue = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJjZXJlbWEuZnIiLCJpYXQiOjE1MzIzNTA4MDAsImV4cCI6MjUzMjM1MDgwMCwic3ViIjoiQWxhaW4gQ0hBUkxFUyIsImFkbWluIjp0cnVlfQ.Rgkgb4KvxY2wp2niXIyLJNJeapFp9z3tCF-zK6Omc8c';
  const validJWTToken = new NbAuthJWTToken(validJWTValue, 'dummy');
  const expiredJWTToken = new NbAuthJWTToken('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzY290Y2guaW8iLCJleHAiOjEzMDA4MTkzODAsIm5hbWUiOiJDaHJpcyBTZXZpbGxlamEiLCJhZG1pbiI6dHJ1ZX0.03f329983b86f7d9a9f5fef85305880101d5e302afafa20154d094b229f75773','dummy');
  const authHeader = 'Bearer ' + validJWTValue;

  let authService: NbAuthService;
  let tokenService: NbTokenService;
  let dummyAuthStrategy: NbDummyAuthStrategy;

  let http: HttpClient;
  let httpMock: HttpTestingController;

  function filterInterceptorRequest(req: HttpRequest): boolean {
    return ['/filtered/url']
      .some(url => req.url.includes(url));
  }

  beforeEach(() => {
github akveo / nebular / 3.6.2 / assets / examples / azure / azure.module.ts View on Github external
} from '@nebular/theme';

import { NbAuthModule } from '@nebular/auth';

import { AzureLoginComponent } from './azure-login.component';
import { AzureCallbackComponent } from './azure-callback.component';
import { AuthAzureToken, AzureADB2CAuthStrategy } from './azure-adb2c-auth-strategy';
import { AzureRoutingModule } from './azure-routing.module';


@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    HttpClientModule,
    NbAuthModule.forRoot({
      strategies: [
        AzureADB2CAuthStrategy.setup({
          name: 'azure',
          clientId: 'bde728e2-2809-4ff1-bc9c-7fcb23800ebe',
          clientSecret: '',
          authorize: {
            endpoint: 'https://login.microsoftonline.com/01513fd2-16a0-453b-9fa0-c9089bfa023e/oauth2/authorize',
            responseType: 'id_token',
            scope: 'openid',
            redirectUri: 'https://akveo.github.io/nebular/example/azure/callback',
            params: {
              p: 'b2c_1_nebular',
            },
          },
          token: {
            class: AuthAzureToken,
github akveo / nebular / 3.6.2 / assets / examples / auth / auth.module.ts View on Github external
]
    .some(url => req.url.includes(url));
}

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    HttpClientModule,
    AuthPlaygroundRoutingModule,

    NbCardModule,
    NbLayoutModule,
    NbListModule,

    NbAuthModule.forRoot({
      forms: {
        login: {
          strategy: 'password',
          redirectDelay: 1000,
          socialLinks: [
            {
              url: 'https://github.com/akveo',
              target: '_blank',
              title: 'GitHub',
            },
            {
              url: 'https://www.facebook.com/akveo',
              target: '_blank',
              icon: 'nb-home',
            },
            {
github akveo / nebular / assets / examples / smart-home / app.module.ts View on Github external
import { NbAuthModule, NbDummyAuthStrategy } from '@nebular/auth';
import { AppComponent } from './app.component';
import { AppRouting } from './app-routing.module';


@NgModule({
  imports: [
    CommonModule,
    HttpClientModule,
    NbLayoutModule,
    NbCardModule,
    NbButtonModule,
    AppRouting,

    NbAuthModule.forRoot({
      strategies: [
        NbDummyAuthStrategy.setup({
          name: 'email',

          alwaysFail: true,
          delay: 1000,
        }),
      ],
    }),
  ],
  declarations: [
    AppComponent,
  ],
})
export class AppModule {
}
github akveo / nebular / assets / examples / oauth2-password / oauth2-password.module.ts View on Github external
@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    HttpClientModule,
    RouterModule,
    RouterModule.forChild([
      {
        path: '',
        component: NbOAuth2PasswordLoginComponent,
      },
    ]),

    NbAuthModule.forRoot({
      forms: {
        login: {
          redirectDelay: 3000,
          showMessages : {
            error: true,
            success: false,
          },
          strategy: 'password',
        },
      },
      strategies: [
         NbOAuth2AuthStrategy.setup({
          name: 'password',
          clientId: 'Aladdin',
          clientSecret: 'open sesame',
          clientAuthMethod: NbOAuth2ClientAuthMethod.BASIC,
github akveo / nebular / src / playground / with-layout / oauth2-password / oauth2-password.module.ts View on Github external
NbOAuth2AuthStrategy,
  NbOAuth2ClientAuthMethod,
  NbOAuth2GrantType,
} from '@nebular/auth';

import { OAuth2PasswordLoginComponent } from './oauth2-password-login.component';
import { Oauth2PasswordRoutingModule } from './oauth2-password-routing.module';


@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    HttpClientModule,

    NbAuthModule.forRoot({
      forms: {
        login: {
          redirectDelay: 3000,
          showMessages : {
            error: true,
            success: false,
          },
          strategy: 'password',
        },
      },
      strategies: [
         NbOAuth2AuthStrategy.setup({
          name: 'password',
          clientId: 'Aladdin',
          clientSecret: 'open sesame',
          clientAuthMethod: NbOAuth2ClientAuthMethod.BASIC,
github akveo / nebular / packages-smoke / src / app / app.module.ts View on Github external
import { NbThemeModule } from '@nebular/theme';
import { NbAuthModule } from '@nebular/auth';
import { NbSecurityModule } from '@nebular/security';
import { NbMomentDateModule } from '@nebular/moment';
import { NbDateFnsDateModule } from '@nebular/date-fns';
import { NbEvaIconsModule } from '@nebular/eva-icons';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    NbThemeModule.forRoot({ name: 'default' }),
    NbAuthModule.forRoot(),
    NbSecurityModule.forRoot(),
    NbMomentDateModule,
    NbDateFnsDateModule,
    NbEvaIconsModule,
  ],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {
}
github akveo / nebular / src / playground / without-layout / smart-home / app.module.ts View on Github external
import { NbAuthModule, NbDummyAuthStrategy } from '@nebular/auth';
import { AppComponent } from './app.component';
import { AppRouting } from './app-routing.module';


@NgModule({
  imports: [
    CommonModule,
    HttpClientModule,
    NbLayoutModule,
    NbCardModule,
    NbButtonModule,
    AppRouting,

    NbAuthModule.forRoot({
      strategies: [
        NbDummyAuthStrategy.setup({
          name: 'email',

          alwaysFail: true,
          delay: 1000,
        }),
      ],
    }),
  ],
  declarations: [
    AppComponent,
  ],
})
export class AppModule {
}