Skip to main content

Authentication methods

How sessions work

When a user signs in, Knowledge Stack issues a session token as an httpOnly cookie called ks_uat. This cookie is automatically sent with every subsequent API request — no need to manage tokens manually.
  • The session cookie is secure and not accessible to client-side JavaScript.
  • Sessions are scoped to a specific tenant. To switch tenants, refresh the token via the /auth/uat endpoint.

Email/password authentication

Sign-up flow

  1. Verify email — Call POST /auth/pw/email_verification with the user’s email. They’ll receive a verification token.
  2. Create account — Call POST /auth/pw/user with the verification token and their chosen password.

Sign-in

On success, the response sets the ks_uat session cookie. Include this cookie in all subsequent requests.

Password reset

Two flows are available:
  • Authenticated reset — A signed-in user calls POST /auth/pw/reset with their current and new password.
  • Forgot password — Call POST /auth/pw/send_reset_email, then POST /auth/pw/reset_with_token with the emailed token.

SSO (Google and Tenant providers)

Knowledge Stack implements the Authorization Code with PKCE flow for SSO.

SSO flow

  1. Initiate — Call POST /auth/sso/initiate with the provider type. The response includes an authorization URL.
  2. Redirect — Redirect the user to the authorization URL. They authenticate with their identity provider.
  3. Callback — The provider redirects back to your application. The callback endpoint (GET /auth/sso/oauth2/callback) exchanges the authorization code for a session and sets the ks_uat cookie.
OAuth state and PKCE parameters are handled securely via encrypted cookies — your application never needs to manage these values directly.

Tenant switching

A user can belong to multiple tenants. To switch the active tenant:
This issues a new session cookie scoped to the specified tenant.

Signing out

Clears the session cookie and ends the session.

API reference