Nexeed
    • Introduction
    • User manual
      • Basic operation
      • Getting started
      • User
      • Groups
      • Roles
      • Organizations
      • Contracts
      • Modules
      • Identity providers
        • General Settings for the Identity Provider
        • Mapper Overview
      • Reports
      • Activity log
      • My Account
        • Overview: Login Tab
      • Configuration
        • Contents of the configuration file
        • How to work with the configuration file
    • Operations manual
      • Overview
      • System Architecture and Interfaces
      • System Requirements
        • macma/macma-webapp-backend
        • macma/macma-core
        • macma/macma-keycloak-mssql
      • Migration from Previous Versions
        • Migration to 1.37+
        • Migration to 1.34+
        • Migration to 1.33+
        • Migration to 1.32+
        • Migration to 1.31+
        • Migration to 1.29+
        • Migration to 1.28+
        • Migration to 1.27+
        • Migration to 1.26+
        • Migration to 1.25+
        • Migration to 1.21+
        • Migration to 1.20+
        • Migration to 1.19+
        • Migration to 1.18+
        • Migration to 1.17+
        • Migration to 1.16.0
        • Migration to 1.15.0
      • Setup and Configuration
        • Helm Configuration
        • macma/macma-core Configuration
        • macma/macma-keycloak-mssql Configuration
        • macma/macma-webapp-backend Configuration
        • Installation guide
        • Identity provider integration
        • Optional Configuration
        • Recommendations
        • Module Health Verification Endpoints and K8S Probes
      • Start and Shutdown
      • Regular Operations
        • Registering a new application in MACMA
          • Allowing application to use other applications
        • Change client secret of an application
      • Logging and Monitoring
        • Required Monitoring
        • Security Logging
          • Macma Security Events
          • Keycloak Security Events
          • Security Logging Format
        • Activity Logging
          • Activity Log Events
      • Known Limitations
        • Performance
        • General
        • Allowed characters and Internationalization
    • Developer documentation
      • Concepts
        • Authentication
        • Authorization
        • Resources
        • Roles
        • Sharing
      • Getting started
        • Registration
        • Authentication
        • Authorization
        • Multitenancy
      • How-to
        • Get & handle tokens
        • OAuth 2.0 for Mobile and Native Apps
        • Evolve authorization in your application lifecycle
        • Use Web Core for user login
        • Handle our integration events
        • Frequent How-To Questions for Application Developers
        • Do automated testing
        • Advertise things to colleagues
        • Integrate with additional environments
      • Deep dives
        • OAuth2 and its flows
        • OpenID Connect endpoints
    • Troubleshooting
      • Startup and availability
      • Identity provider integration
      • Resource deletion
      • Authentication
      • Authorization
    • API documentation
      • HTTP API
      • Event API
    • Glossary
Multitenant Access Control
  • Industrial Application System
  • Core Services
    • Block Management
    • Deviation Processor
    • ID Builder
    • Multitenant Access Control
    • Notification Service
    • Ticket Management
    • Web Portal
  • Shopfloor Management
    • Andon Live
    • Global Production Overview
    • KPI Reporting
    • Operational Routines
    • Shift Book
    • Shopfloor Management Administration
  • Product & Quality
    • Product Setup Management
    • Part Traceability
    • Process Quality
    • Setup Specs
  • Execution
    • Line Control
    • Material Management
    • Order Management
    • Packaging Control
    • Rework Control
  • Intralogistics
    • Stock Management
    • Transport Management
  • Machine & Equipment
    • Condition Monitoring
    • Device Portal
    • Maintenance Management
    • Tool Management
  • Enterprise & Shopfloor Integration
    • Archiving Bridge
    • Data Publisher
    • Engineering UI
    • ERP Connectivity
    • Gateway
    • Information Router
    • Master Data Management
    • Orchestrator

Nexeed Learning Portal

  • Multitenant Access Control
  • Developer documentation
  • How-to
  • Use Web Core for user login
1.38 1.37.1

How to use the Bosch Web Core library for user login

For user login using Authorization Code Grant Flow with PKCE without involving the backend, we recommend using Bosch Connected Industry Web Core Auth for your Angular application. It provides a "MacmaAuthModule" handling OAuth2 for you including multitenancy and consuming access control lists.

BCI Web Core is currently only available for Bosch-internal projects

This is an example for using BCI Web Core Auth:

@NgModule({
    imports: [
        // we import the module into our main module's imports
        MacmaAuthModule.forRoot({
            authOptionsProvider: {
                provide: AUTH_OPTIONS,
                useFactory: authOptionsFactory,
                deps: [CoreConfigurationService],
            },
        }),
    ]
]);

With the authOptionsFactory to provide configuration based on the auth server URL and client ID provided by the backend’s config endpoint.

export function authOptionsFactory(coreConfigurationService: CoreConfigurationService): IAuthModuleConfig {
    const config$ = from(coreConfigurationService.configPromise).pipe(
        first(),
        catchError((e) => {
            console.log('Core config failed', e);
            return of(e);
        }),
        shareReplay(1)
    );

    return {
        ...DefaultMacmaAuthModuleConfig,
        debugAuthentication: false,
        autoLogin: true,
        requestUserInfo: true,
        useRefreshToken: true,

        // Whether to use scoped storage for concurrent login flows of
        // the same application. Relevant when multiple application
        // instances run from same origin (e.g. widgets) but may impact
        // performance.
        useStorageScope: true/false,

        // No auth header for assets so that they are cached by browser.
        addAuthHeader: req => !req.url.includes('./assets'),
        accessControlEndpoint: config$.pipe(
            map(config => config.endpoint)
        ),
        clientId: config$.pipe(
            map(config => config.clientId),
        ),
        defaultRealm: config$.pipe(
            map(config => config.defaultRealm),
        ),
    } as IMacmaAuthModuleConfig;
}

Login.html, login.css and oidc-callback-handling.js from BCI Web Core Auth can be used by configuring in your angular.json at projects.<your-project>.architect.build.options.assets:

{
    "glob": "**/*",
    "input": "./node_modules/@bci-web-core/auth/dist/assets",
    "output": "/assets"
},

This will make those assets available at /assets/auth, e.g. /assets/auth/login.html. Please make sure to change styling and legal contents (footer) as required. The library expects a login.html sending an oidc-code-message event and a renew.html sending a oidc-silent-renew-message event each containing the url as the event details. Please don’t use those pages blindly, you need to consider your legal requirements, e.g. a footer.

Finally, upon encountering a 401 UNAUTHORIZED indicating that a user is no longer logged in, check whether the application state is as if the user was still logged in and take measures to update the state:

if (!!this.authenticationService.getUsername()) {
    // user seems to be logged in but token is not valid any more because it was from a previous SSO session
    // logout required to make login callback state handling work
    this.oidcSecurityService.logoffLocal();
    (this.authenticationService as MacmaAuthenticationService).login();
}

Contents

© Robert Bosch Manufacturing Solutions GmbH 2023-2025, all rights reserved

Changelog Corporate information Legal notice Data protection notice Third party licenses