Whitelist exact redirect URIs
Never use wildcard callback domains for third-party applications. Register the production HTTPS redirect and any separate local development callback explicitly.
Configure a development identity provider, register your client, and integrate a standards-based browser sign-in flow.
The repository includes an optional Keycloak + PostgreSQL environment in identity/provider/. Keycloak handles account management, token issuance, signing keys, OIDC discovery, and consent. The database persists local test accounts.
cd identity/provider
cp .env.example .env
# Choose strong, local-only credentials in .env
# Launch Docker Desktop first
docker compose up -dAfter the development service is healthy, the issuer is http://localhost:8080/realms/magnexis. View its /.well-known/openid-configuration endpoint to inspect the discovery metadata. The imported development client is magnexis-local-web.
In Keycloak’s admin console, create a separate OIDC client for each application. Enable the authorization code flow and require PKCE S256. Configure exact allowed redirect URIs and web origins. Public browser clients must not use embedded client secrets. Do not use wildcard production redirect URIs.
Source is included under identity/sdk/. This is a private development package, not yet available on npm.
# From your application directory; replace path as needed
npm install ../path-to-magnexis/identity/sdkimport { MagnexisAuth } from '@magnexis/identity';
const auth = new MagnexisAuth({
issuer: 'http://localhost:8080/realms/magnexis',
clientId: 'magnexis-local-web',
redirectUri: 'http://localhost:5173/callback',
postLogoutRedirectUri: 'http://localhost:5173/',
});
// On user click:
await auth.signIn();
// On your configured callback route only:
const user = await auth.handleCallback();
console.log(user.profile.sub);An OpenID Connect issuer publishes signed key discovery and metadata. Use its discovery document rather than hard-coding authorization or token endpoints:
{issuer}/.well-known/openid-configurationRead jwks_uri from discovery metadataRead authorization_endpoint + token_endpoint from discoveryThe public Magnexis website can deploy on Netlify, but the identity issuer must run on a long-lived, hardened service with TLS, protected administrative access, trusted mail delivery, backups, logging, and rate limiting. Never host real authentication by imitating it on a static Netlify form.
OpenID Connect is a protocol contract. A working sign-in button alone does not verify that contract.
Never use wildcard callback domains for third-party applications. Register the production HTTPS redirect and any separate local development callback explicitly.
Validate issuer, audience, signature, lifetime, nonce, and any application-specific constraints. Do not rely solely on decoding token payloads in browser JavaScript.
Before accepting real users, test cancellation, expiry, revocation, provider downtime, session renewal, logout, and error displays with a clear route for support.