Skip to content

Auth Hook

Determine the validity of the session in onBeforeHandle, and return sessionStatus and sessionClaims from the resolve hook.

const rp = await OidcClient.factory({
authHookSettings: {
loginRedirectUrl: "/path/to/login",
disableRedirect: false,
// ...
},
//...
});
const authHook = rp.authHook;
  • If the session is valid:
  • If the session is invalid:
    • Redirect to loginRedirectUrl.
    • If disableRedirect is true, both sessionStatus and sessionClaims will be null.
  • ElysiaJS plugin metadata
    • name: elysia-openid-client-auth-hook
    • seed: settings.pluginSeed or else issuerUrl
  • Ref: OIDCClientAuthHookSettings