Skip to content

Init OIDC in UI based on config endpoint #318

Description

@andrei2699

using angular-auth-oidc-client

call /api/config endpoint to receive something like

app.MapGet("/api/config/auth", (IConfiguration config) => Results.Ok(new
{
    Authority = config["Authentication:Authority"],
    ClientId = config["Authentication:ClientId"],
    Scope = config["Authentication:Scope"]
}));

based on these info populate the config tokens

// main.ts
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';
import { appConfig } from './app/app.config';
import { AUTH_CONFIG_TOKEN } from './app/auth-config.token';

async function bootstrap() {
  // Fetch C# backend settings
  const response = await fetch('/api/config/auth');
  const authConfig = await response.json();

  bootstrapApplication(AppComponent, {
    providers: [
      ...appConfig.providers,
      { provide: AUTH_CONFIG_TOKEN, useValue: authConfig }
    ]
  });
}

bootstrap().catch(err => console.error(err));

Metadata

Metadata

Assignees

Labels

area/authAuthentication and Authorizationarea/uiScriptBee Client

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions