@sinequa/atomic

Authentication

Which mode your deployment uses, why you rarely choose it, and what your interface has to render in each case.

You do not pick how users sign in — the server does, and it announces it. Your job is smaller than it looks: call login(), and render either a loader or a credentials form depending on what came back.

the whole of it, most of the time
await client.initializeConfig(); // asks the server how it authenticates
await client.auth.login();       // does it

Everything below exists because that pair behaves differently per deployment, and because sessions expire.

Which mode is yours?

OAuth / OIDC SAML no Windows / IIS,reverse proxy, SPFx no no — server to server yes How does the server authenticate? Is a providerconfigured? oauthfull-page redirect samlfull-page redirect Does the transportauthenticate itself? ssonothing to render Is there a browser? bearera configured token credentialsa username and password form

If you cannot answer the first question, that is the normal case: leave the mode alone and let it be detected.

The modes

ModeSign-inWhat your interface renders
credentialsUsername and password posted to the serverA form. login() with no arguments returns false.
ssoThe transport authenticates every request — Windows integrated auth, a reverse proxy, an SPFx hostNothing. A loader at most.
oauthFull-page redirect to an identity provider, and backA loader; the page is left.
samlThe same, with a SAML providerA loader; the page is left.
bearerA configured access token sent on every requestNothing — usually there is no interface.
unknownNot resolved yet: the defaultWait. It becomes one of the above.

One predicate covers the rendering decision, and it exists so nobody has to enumerate that list again:

loader or form?
import { isExternalAuthMode } from "@sinequa/atomic";

// true for sso, oauth, saml and bearer — every mode that needs no form.
if (isExternalAuthMode(client.config.authMode)) showLoader();
else showCredentialsForm();

unknown is deliberately not external: treating an unresolved mode as formless risks a loader with no way out.

Declaring it explicitly

When you know, say so — an explicit mode other than unknown always wins over what the server announces:

taking the decision away from detection
import { AuthMode } from "@sinequa/atomic";

client.configure({ authMode: AuthMode.sso() });
client.configure({ authMode: AuthMode.oauth("my-provider") });
client.configure({ authMode: AuthMode.bearer(token) });
client.configure({ authMode: AuthMode.bearer(token, { sessionCookie: false }) });
client.configure({ authMode: AuthMode.credentials() });

Declaring credentials is also an optimisation: initializeConfig() then makes no pre-login request, since a form needs nothing from the server.

Per mode

On this page