Skip to main content

Authentication Service

The Authentication Service provides secure user authentication and authorization capabilities across your organization’s ecosystem. It manages user identity verification, session handling, and supports multiple authentication methods including password, one-time passwords (OTP), OAuth providers (Google, Microsoft), Azure AD, OAuth, and SAML SSO.

Base URL

All endpoints are prefixed with /api/v1

Authentication

Most endpoints require authentication via Bearer token:
Internal endpoints use scoped token authentication for service-to-service communication with specific scopes:
  • PASSWORD_RESET - For password reset operations
  • TOKEN_REFRESH - For token refresh operations
  • FETCH_CONFIG - For configuration updates

Architecture Overview

The Authentication Service is built on a Node.js backend with MongoDB for data persistence and Redis for session management. The service implements a container-based dependency injection pattern using InversifyJS for better modularity and testability. Key components that the Auth Service integrates with:
  • IAM Service - Manages user and organization information
  • Configuration Manager - Stores authentication provider configurations
  • Communication Service - Handles email delivery for password resets and OTP
  • Redis - Manages authentication sessions and temporary tokens

Authentication Flow Process

The Auth Service employs a multi-step session-based authentication flow:
  1. Authentication Initialization
    • Client calls the /userAccount/initAuth endpoint with an email
    • Server validates the email and creates a temporary session in Redis
    • Server returns a session token in the x-session-token response header along with available authentication methods
  2. Authentication Steps
    • Client calls /userAccount/authenticate with the session token in the x-session-token header
    • Client provides chosen authentication method and credentials
    • The method must be one the organization allows for the current step. Any other method is refused with 400 before any password or code is checked
    • If multi-factor authentication is configured, the server returns information about the next step
    • Client repeats the authentication step with appropriate credentials until all required steps are completed
    • Every step must be completed by the same account. A later step completed for a different account (for example a different Google, Microsoft, OAuth or SAML identity) is refused, and no account is created for it
  3. Token Issuance
    • After successful authentication, the server issues access and refresh tokens
    • The Redis session is cleared
    • Client stores tokens for subsequent API calls
Here’s a sequence diagram of the flow:

Data Models

Session Management with Redis

The Auth Service uses Redis to store temporary session data during the authentication process:
  • Sessions are identified by a unique UUID token
  • The x-session-token header is used to track the session across requests
  • Sessions expire after a configurable period (default: 1 hour)
  • Session data includes authentication state, user info, and available auth methods
  • After successful authentication, sessions are deleted from Redis

Token-Based Authentication

After successful authentication, the service issues two types of JWTs:
  1. Access Token
    • Short-lived token (typically 1 hour)
    • Contains user ID, organization ID, user email, and permissions
    • Used for authorizing API requests across services
  2. Refresh Token
    • Longer-lived token (typically 7 days)
    • Used to obtain new access tokens when they expire
    • Prevents the need for frequent re-authentication
Both tokens are cryptographically signed with JWT secrets to ensure authenticity.

API Endpoints

Core authentication endpoints for initializing and completing the authentication process.
Start the authentication process for a user.
Endpoint: POST /api/v1/userAccount/initAuthRequest Body Parameters:
Perform authentication with credentials for a specific method.
Endpoint: POST /api/v1/userAccount/authenticateHeaders:Request Body Parameters:
SAML uses browser redirects, so it has its own sign-in route, GET /api/v1/saml/signIn. Sending "method": "samlSso" to this endpoint returns 400 with “Single sign-on (SAML) can’t be completed with this request. On the sign-in page, choose your organisation’s single sign-on option. Apps calling the API directly should send the browser to /api/v1/saml/signIn instead.”
Authentication Methods:
Password Authentication
OTP Authentication
Google Authentication
Microsoft Authentication
Azure AD Authentication
OAuth Authentication
One-time password generation and validation.
Generate and send an OTP to the user’s email.
Endpoint: POST /api/v1/userAccount/login/otp/generateRequest Body Parameters:Validation:
  • Email must be in valid email format
  • Request goes through ValidationMiddleware with email validation
OAuth token exchange and provider integration.
Exchange OAuth authorization code for tokens.
Endpoint: POST /api/v1/userAccount/oauth/exchangeRequest Body Parameters:
Password reset, change, and recovery operations.
Initiate password reset process via email.
Endpoint: POST /api/v1/userAccount/password/forgotRequest Body Parameters:
Reset password using token from email.
Endpoint: POST /api/v1/userAccount/password/reset/tokenHeaders:Request Body Parameters:
Change password for authenticated user.
Endpoint: POST /api/v1/userAccount/password/resetHeaders:Request Body Parameters:
Token refresh and session management operations.
Refresh access token using refresh token.
Endpoint: POST /api/v1/userAccount/refresh/tokenHeaders:Request Body Parameters: No body parameters required.
Logout user and invalidate session.
Endpoint: POST /api/v1/userAccount/logout/manualHeaders:Request Body Parameters: No body parameters required.
SAML Single Sign-On authentication and configuration.
Initiate SAML authentication flow.
Endpoint: GET /api/v1/saml/signInQuery Parameters:
Handle SAML authentication response from Identity Provider.
Endpoint: POST /api/v1/saml/signIn/callbackThis endpoint is called by the Identity Provider after successful authentication. No manual parameters needed as this is part of the SAML flow.
Update SAML application configuration.
Endpoint: POST /api/v1/saml/updateAppConfigHeaders:
Manage organization-wide authentication settings and methods.
Retrieve current authentication methods configuration.
Endpoint: GET /api/v1/orgAuthConfig/authMethodsHeaders:
Update organization authentication methods configuration.
Endpoint: POST /api/v1/orgAuthConfig/updateAuthMethodHeaders:Request Body Parameters:Auth Method Structure:
Validation Rules:
  • Must have between 1 and 3 authentication steps
  • Each step must have a unique order number
  • At least one authentication method is required per step
  • No duplicate authentication methods within the same step
  • No duplicate authentication methods across different steps
  • Each authentication method can only be used once in the entire configuration
  • samlSso can only be used in a one-step configuration. A configuration with more than one step that includes samlSso in any step is refused with 400: “SAML single sign-on can’t be combined with other sign-in steps yet. Use SAML on its own as a one-step sign-in, or remove it from the policy.” One step that offers SAML alongside other methods (for example SAML or password) is allowed
Supported Authentication Types:
  • password - Username/password authentication
  • otp - One-time password via email
  • google - Google OAuth authentication
  • microsoft - Microsoft OAuth authentication
  • azureAd - Azure Active Directory authentication
  • oauth - Generic OAuth authentication
  • samlSso - SAML Single Sign-On
Initialize organization authentication configuration.
Endpoint: POST /api/v1/orgAuthConfig/Headers:Request Body Parameters:
Internal service-to-service endpoints for configuration and validation.
Check if password authentication is enabled for the organization.
Endpoint: GET /api/v1/userAccount/internal/password/checkHeaders:

Security Considerations

The Authentication Service implements several security measures:

Password Security

  • Passwords are validated for complexity requirements (minimum 8 characters with at least one uppercase, one lowercase, one number, and one special character)
  • Passwords are hashed using bcrypt with salt rounds
  • Forgot-password links work once and expire after 20 minutes. Self-hosted deployments can change that lifetime with the PASSWORD_RESET_LINK_EXPIRY environment variable (for example 30m). Invitation links are separate: a link to set a first password lasts 48 hours and ignores that setting. When password sign-in is turned off, the invitation links to the sign-in page instead, so it doesn’t expire

Brute Force Protection

  • Failed login attempts are tracked per user account
  • Accounts are automatically blocked after 5 consecutive failed attempts
  • Suspicious login attempts trigger notification emails
  • Blocked accounts require admin intervention to restore access

Session Security

  • Session tokens are generated as UUIDs
  • Sessions have limited lifetime (default: 1 hour) and are stored in Redis
  • Sessions are invalidated after successful authentication or timeout
  • Session data is encrypted and contains minimal user information

JWT Security

  • Tokens are signed with secure secrets
  • Different scopes are used for different token types (auth, refresh, password reset, etc.)
  • Access tokens have short lifetimes (typically 1 hour)
  • Refresh tokens have longer lifetimes (typically 7 days)

OAuth Security

  • OAuth tokens are validated against provider endpoints
  • Email verification ensures token authenticity
  • Provider-specific validation for Google, Microsoft, and Azure AD
  • Generic OAuth support with configurable endpoints

SAML Security

  • SAML responses are cryptographically verified
  • Certificate-based validation
  • Configurable email field mapping
  • Relay state protection against CSRF attacks

Error Handling

Errors use the API’s standard shape:
requestId is included when the request has one. The codes you’ll see from these endpoints:
  • HTTP_BAD_REQUEST - A request the service refuses, including a wrong password (see the /authenticate error table)
  • HTTP_UNAUTHORIZED - A missing, invalid or expired sign-in token or sign-in session; a failed sign-in-code check (wrong, expired or already-used code, no code requested, unknown email, or a locked account); or a sign-in step completed with a different account. A wrong current password on the change-password endpoint is also HTTP_UNAUTHORIZED (“Current password is incorrect.”). On /authenticate, a wrong password is HTTP_BAD_REQUEST instead
  • HTTP_FORBIDDEN - Not allowed, for example an OAuth token without the required scope
  • HTTP_NOT_FOUND - Resource not found
  • VALIDATION_ERROR - The request body or parameters don’t match the expected format
  • INTERNAL_ERROR - A failure on PipesHub’s side; the message doesn’t describe internals
There is no separate code for a locked account. A locked account gets the same answer as a wrong password (HTTP_BAD_REQUEST) or a wrong sign-in code (HTTP_UNAUTHORIZED), so that sign-in doesn’t reveal whether an account exists.

Important Notes

  1. Session Token Management: The x-session-token header is critical for multi-step authentication flows
  2. Password Complexity: Passwords must meet minimum security requirements
  3. Account Blocking: Users are automatically blocked for 24 hours after 5 failed login attempts, and the owner is emailed. Sign-in answers a blocked account the same way as a wrong password or code
  4. Token Scopes: Different endpoints require different token scopes for access
  5. Multi-Factor Authentication: Organizations can configure multiple authentication steps
  6. Provider Configuration: OAuth and SAML providers require proper configuration
  7. Email Validation: All email fields are validated for proper format
  8. Security Headers: Proper headers must be included for authentication flows