Authentication
@archibald/commerce/auth implements the @archibald/auth provider contract against the SAP Commerce OAuth server (authorizationserver): user login (password grant or OIDC) and client-credential access for anonymous traffic.
How to use
Register both providers with the AuthModule — CommerceUserAuthProvider authenticates users, CommerceStaticAuthProvider supplies the client-credentials token unauthenticated requests ride on:
// src/{platform}/server/module/server.tsx
import { AuthModule } from '@archibald/auth';
import { CommerceUserAuthProvider, CommerceStaticAuthProvider } from '@archibald/commerce/auth';
new AuthModule({
providers: [
new CommerceUserAuthProvider({
config: () => this.configService.get('hybris.api'),
credentials: () => this.configService.get('hybris.oauth')
}),
new CommerceStaticAuthProvider({
config: () => this.configService.get('hybris.api'),
credentials: () => this.configService.get('hybris.oauth')
})
],
options: () => ({
strategy: { type: 'header' },
token: { secret: this.configService.get('server.credentials.token.secret') },
refresh: { secret: this.configService.get('server.credentials.token.secret') }
})
});
For OIDC (authorization-code flow against the Hybris IdP or a mock), the provider discovers the endpoints from GET {hybris.api}/authorizationserver/oauth/ — the OIDC setup guide walks through it end to end.
The user provider is the extension seam: the shop template's portal platform subclasses it (CommerceB2BUserAuthProvider extends CommerceUserAuthProvider) to enrich the session with B2B org data.
API reference
| Export | Side | What it is |
|---|---|---|
CommerceUser, auth interfaces | client | Typed user/session shapes shared with your components |
CommerceUserAuthProvider | server | UserAuthProvider against the OCC OAuth server (password + OIDC); subclass to extend the session |
CommerceStaticAuthProvider | server | Client-credentials provider for anonymous OCC access |
| user mapper, user mocks | server | OCC user → CommerceUser mapping and fixtures |
Configuration
hybris.api— OCC/OAuth host, throughconfig.hybris.oauth—client_id,client_secret(inject via a{{VAR}}environment placeholder, never committed), optionalscope/redirect_uri, throughcredentials.server.credentials.token.secret— the 32-character JWE session secret theAuthModulerequires.
Further documentation
- Authentication guide — strategies, sessions, the module's options.
- OIDC setup guide — the full flow against SAP Commerce.