How to use angular-oauth2-oidc - 10 common examples

To help you get started, we’ve selected a few angular-oauth2-oidc 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 fabric8-ui / fabric8-ui / packages / fabric8-ui / src / a-runtime-console / kubernetes / service / kubernetes.restangular.ts View on Github external
// console.log("===== setting kubernetes token: " + (token ? "token" : "no token") + " for " + url);
        headers['Authorization'] = `Bearer ${onLogin.token}`;
        return {
          params,
          headers,
          element,
        };
      },
    );
  });
  return config;
}

@NgModule({
  imports: [OAuthModule.forRoot()],
  providers: [
    {
      provide: KUBERNETES_RESTANGULAR,
      useFactory: KubernetesRestangularFactory,
      deps: [Restangular, OAuthService, OnLogin],
    },
  ],
})
export class KubernetesRestangularModule {}
github btpka3 / btpka3.github.com / js / angular / my-ng4 / src / app / app.component.ts View on Github external
private configureWithNewConfigApi() {
    this.oauthService.configure(authConfig);
    this.oauthService.tokenValidationHandler = new JwksValidationHandler();
    this.oauthService.loadDiscoveryDocumentAndTryLogin();
    this.oauthService.setupAutomaticSilentRefresh();

    this.oauthService.events.subscribe(e => {
      console.debug('oauth/oidc event', e);
    });

    this.oauthService.events.filter(e => e.type === 'session_terminated').subscribe(e => {
      console.debug('Your session has been terminated!');
    });

    this.oauthService.events.filter(e => e.type === 'token_received').subscribe(e => {
      // this.oauthService.loadUserProfile();
    });

  }
github manfredsteyer / angular-oauth2-oidc / sample / src / app / app.component.ts View on Github external
private configureWithNewConfigApi() {

      this.oauthService.configure(authConfig);
      this.oauthService.tokenValidationHandler = new JwksValidationHandler();
      this.oauthService.loadDiscoveryDocumentAndTryLogin();

      // Optional
      this.oauthService.setupAutomaticSilentRefresh();

      this.oauthService.events.subscribe(e => {
        console.debug('oauth/oidc event', e);
      });

      this.oauthService.events.filter(e => e.type === 'session_terminated').subscribe(e => {
        console.debug('Your session has been terminated!');
      });
      
      this.oauthService.events.filter(e => e.type === 'token_received').subscribe(e => {
        // this.oauthService.loadUserProfile();
      });
github manfredsteyer / angular-oauth2-oidc / projects / sample / src / app / app.component.ts View on Github external
private configureImplicitFlow() {
    this.oauthService.configure(authConfig);
    // this.oauthService.setStorage(localStorage);
    this.oauthService.tokenValidationHandler = new JwksValidationHandler();
    this.oauthService.loadDiscoveryDocumentAndTryLogin();


    // Optional
    this.oauthService.setupAutomaticSilentRefresh();

    // Display all events
    this.oauthService.events.subscribe(e => {
      // tslint:disable-next-line:no-console
      console.debug('oauth/oidc event', e);
    });

    this.oauthService.events
      .pipe(filter(e => e.type === 'session_terminated'))
      .subscribe(e => {
        // tslint:disable-next-line:no-console
github manfredsteyer / angular-oauth2-oidc / sample / src / app / app.component.ts View on Github external
this.oauthService.redirectUri = window.location.origin + "/index.html";

    // URL of the SPA to redirect the user after silent refresh
    this.oauthService.silentRefreshRedirectUri = window.location.origin + "/silent-refresh.html";

    // The SPA's id. The SPA is registerd with this id at the auth-server
    this.oauthService.clientId = "spa-demo";

    // set the scope for the permissions the client should request
    // The first three are defined by OIDC. The 4th is a usecase-specific one
    this.oauthService.scope = "openid profile email voucher";

    // Url of the Identity Provider
    this.oauthService.issuer = 'https://steyer-identity-server.azurewebsites.net/identity';

    this.oauthService.tokenValidationHandler = new JwksValidationHandler();

    this.oauthService.events.subscribe(e => {
      console.debug('oauth/oidc event', e);
    });

    // Load Discovery Document and then try to login the user
    this.oauthService.loadDiscoveryDocument().then((doc) => {
      this.oauthService.tryLogin();
    });

    this
      .oauthService
      .events
      .filter(e => e.type == 'token_expires')
      .subscribe(e => {
        console.debug('received token_expires event', e);
github manfredsteyer / angular-oauth2-oidc / projects / sample / src / app / app.component.ts View on Github external
// URL of the SPA to redirect the user after silent refresh
    this.oauthService.silentRefreshRedirectUri =
      window.location.origin + '/silent-refresh.html';

    // The SPA's id. The SPA is registerd with this id at the auth-server
    this.oauthService.clientId = 'spa-demo';

    // set the scope for the permissions the client should request
    // The first three are defined by OIDC. The 4th is a usecase-specific one
    this.oauthService.scope = 'openid profile email voucher';

    // Url of the Identity Provider
    this.oauthService.issuer =
      'https://steyer-identity-server.azurewebsites.net/identity';

    this.oauthService.tokenValidationHandler = new NullValidationHandler();

    this.oauthService.events.subscribe(e => {
      // tslint:disable-next-line:no-console
      console.debug('oauth/oidc event', e);
    });

    // Load Discovery Document and then try to login the user
    this.oauthService.loadDiscoveryDocument().then(doc => {
      this.oauthService.tryLogin();
    });

    this.oauthService.events
      .pipe(filter(e => e.type === 'token_expires'))
      .subscribe(e => {
        // tslint:disable-next-line:no-console
        console.debug('received token_expires event', e);
github xmlking / ngx-starter-kit / libs / auth / src / lib / auth.module.ts View on Github external
MatInputModule,
  MatFormFieldModule,
  MatTooltipModule,
  MatToolbarModule,
];

@NgModule({
  imports: [
    CommonModule,
    NgxsModule.forFeature([AuthState]),
    RouterModule,
    [...matModules],
    FlexLayoutModule,
    ReactiveFormsModule,
    FontAwesomeModule,
    OAuthModule.forRoot({
      resourceServer: {
        allowedUrls: [environment.API_BASE_URL, environment.DOCS_BASE_URL],
        sendAccessToken: true,
      },
    }),
  ],
  declarations: [LoginComponent],
  entryComponents: [LoginComponent],
  providers: [
    ROPCService,
    AuthService,
    AuthGuard,
    { provide: ValidationHandler, useClass: JwksValidationHandler },
    // NOTE: for CodeFlow use NullValidationHandler
    // { provide: ValidationHandler, useClass: NullValidationHandler },
  ],
github caos / zitadel / console / src / app / app.module.ts View on Github external
scope: 'openid profile email', // offline_access
  responseType: 'code',
  oidc: true,
};

@NgModule({
  declarations: [
    AppComponent,
    SignedoutComponent,
  ],
  imports: [
    AppRoutingModule,
    CommonModule,
    BrowserModule,
    OverlayModule,
    OAuthModule.forRoot({
      resourceServer: {
        allowedUrls: ['https://test.api.zitadel.caos.ch/caos.zitadel.auth.api.v1.AuthService', 'https://test.api.zitadel.caos.ch/oauth/v2/userinfo', 'https://test.api.zitadel.caos.ch/caos.zitadel.management.api.v1.ManagementService/', 'https://preview.api.zitadel.caos.ch'],
        sendAccessToken: true,
      },
    }),
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useClass: WebpackTranslateLoader,
      },
    }),
    MatNativeDateModule,
    QuicklinkModule,
    AccountsCardModule,
    HasRoleModule,
    BrowserAnimationsModule,
github GoogleCloudPlatform / professional-services / tools / bq-visualizer / src / app / app.module.ts View on Github external
MatButtonModule,
    MatCheckboxModule,
    MatSelectModule,
    MatCardModule,
    MatExpansionModule,
    MatInputModule,
    MatPaginatorModule,
    MatTableModule,
    MatGridListModule,
    MatMenuModule,
    MatIconModule,
    BrowserModule,
    // note to self: import HttpClientModule after BrowserModule, otherwise
    // there is trouble.
    HttpClientModule,
    OAuthModule.forRoot(),
  ],
  providers: [
    {provide: ErrorHandler, useClass: SentryErrorHandler},
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
}
github manfredsteyer / angular-oauth2-oidc / sample / src / app / app.module.ts View on Github external
import {AppRouterModule} from './app.routes';
import {BASE_URL} from './app.tokens';
import {FlightHistoryComponent} from './flight-history/flight-history.component';
import {HomeComponent} from './home/home.component';
import {PasswordFlowLoginComponent} from './password-flow-login/password-flow-login.component';
import {SharedModule} from './shared/shared.module';

@NgModule({
    imports: [
        BrowserModule,
        FormsModule,
        ReactiveFormsModule,
        SharedModule.forRoot(),
        AppRouterModule,
        HttpClientModule,
        OAuthModule.forRoot(
            {
            resourceServer: {
                allowedUrls: ['http://www.angular.at/api'],
                sendAccessToken: true
            }
        }
    )
    ],
    declarations: [
        AppComponent,
        HomeComponent,
        FlightHistoryComponent,
        PasswordFlowLoginComponent
    ],
    providers: [
        // {provide: AuthConfig, useValue: authConfig },

angular-oauth2-oidc

Support for OAuth 2 and OpenId Connect (OIDC) in Angular. Already prepared for the upcoming OAuth 2.1.

MIT
Latest version published 8 months ago

Package Health Score

72 / 100
Full package analysis