Project

boxlang-express-auth

Third-party sign-in for boxlang-express apps: a generic OAuth2 core, a generic OpenID Connect provider, and presets for GitHub, Google, Microsoft, GitLab and Apple. Your app decides who a provider identity is; the module runs the flow, guards routes (WebSocket upgrades included), links extra accounts, and keeps the session honest.

Six ways in

GitHub, Google (with a Workspace domain limit), Microsoft Entra ID (with tenant control), GitLab, Apple, and any OIDC issuer such as Keycloak or Authelia.

The hard parts, done

PKCE on every login, single-use expiring state, session regeneration, and ID tokens checked for signature, issuer, audience, expiry and nonce. Provider tokens are never stored.

Linking and logout

A signed-in user can attach another provider account, and signing out of an OIDC provider can continue at the issuer, so single sign-on ends where it started.

Testable

A test provider signs users in through the real routes from your own specs, with no provider account and no network.

Running on this site"Sign in with Google" and "Sign in with GitHub" here run on boxlang-express-auth, for commenters and for the admin, where a passkey from bx-passkeys is still required on top.
bashinstall-bx-module boxlang-express,boxlang-express-auth --local
javascriptauth = boxExpressAuth( {
	verify  : ( identity, tokens, req ) => users.findOrCreateFromIdentity( identity ),
	loadUser: ( id ) => users.get( id )
} )

auth.provider( "github", boxExpressAuthGitHub( {
	clientId    : getSystemSetting( "GITHUB_CLIENT_ID" ),
	clientSecret: getSystemSetting( "GITHUB_CLIENT_SECRET" ),
	callbackUrl : "https://example.com/auth/github/callback"
} ) )

app.use( boxExpressSession( { resave: false, saveUninitialized: false } ) )
app.use( "/auth", auth.routes() )

app.get( "/dashboard", auth.required(), ( req, res ) => res.json( { user: req.user } ) )

Routes, guards and what happens on the callback →