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:PASSWORD_RESET- For password reset operationsTOKEN_REFRESH- For token refresh operationsFETCH_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:-
Authentication Initialization
- Client calls the
/userAccount/initAuthendpoint with an email - Server validates the email and creates a temporary session in Redis
- Server returns a session token in the
x-session-tokenresponse header along with available authentication methods
- Client calls the
-
Authentication Steps
- Client calls
/userAccount/authenticatewith the session token in thex-session-tokenheader - 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
400before 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
- Client calls
-
Token Issuance
- After successful authentication, the server issues access and refresh tokens
- The Redis session is cleared
- Client stores tokens for subsequent API calls
Data Models
OrgAuthConfig Schema
OrgAuthConfig Schema
UserCredentials Schema
UserCredentials Schema
UserActivities Schema
UserActivities Schema
Session Data
Session Data
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:-
Access Token
- Short-lived token (typically 1 hour)
- Contains user ID, organization ID, user email, and permissions
- Used for authorizing API requests across services
-
Refresh Token
- Longer-lived token (typically 7 days)
- Used to obtain new access tokens when they expire
- Prevents the need for frequent re-authentication
API Endpoints
Authentication Flow
Authentication Flow
POST /userAccount/initAuth - Initialize Authentication
POST /userAccount/initAuth - Initialize Authentication
- Request
- Response
POST /api/v1/userAccount/initAuthRequest Body Parameters:POST /userAccount/authenticate - Authenticate User
POST /userAccount/authenticate - Authenticate User
- Request
- Response
- Error Responses
POST /api/v1/userAccount/authenticateHeaders: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.”OTP Authentication
OTP Authentication
POST /userAccount/login/otp/generate - Generate OTP
POST /userAccount/login/otp/generate - Generate OTP
- Request
- Response
POST /api/v1/userAccount/login/otp/generateRequest Body Parameters:- Email must be in valid email format
- Request goes through ValidationMiddleware with email validation
OAuth Integration
OAuth Integration
POST /userAccount/oauth/exchange - Exchange OAuth Token
POST /userAccount/oauth/exchange - Exchange OAuth Token
- Request
- Response
POST /api/v1/userAccount/oauth/exchangeRequest Body Parameters:Password Management
Password Management
POST /userAccount/password/forgot - Forgot Password
POST /userAccount/password/forgot - Forgot Password
- Request
- Response
POST /api/v1/userAccount/password/forgotRequest Body Parameters:POST /userAccount/password/reset/token - Reset Password with Token
POST /userAccount/password/reset/token - Reset Password with Token
- Request
- Response
POST /api/v1/userAccount/password/reset/tokenHeaders:POST /userAccount/password/reset - Change Password
POST /userAccount/password/reset - Change Password
- Request
- Response
POST /api/v1/userAccount/password/resetHeaders:Token Management
Token Management
POST /userAccount/refresh/token - Refresh Token
POST /userAccount/refresh/token - Refresh Token
- Request
- Response
POST /api/v1/userAccount/refresh/tokenHeaders:POST /userAccount/logout/manual - Logout
POST /userAccount/logout/manual - Logout
- Request
- Response
POST /api/v1/userAccount/logout/manualHeaders:SAML SSO Integration
SAML SSO Integration
GET /saml/signIn - SAML Sign-In
GET /saml/signIn - SAML Sign-In
- Request
- Response
GET /api/v1/saml/signInQuery Parameters:POST /saml/signIn/callback - SAML Callback
POST /saml/signIn/callback - SAML Callback
- Request
- Response
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.POST /saml/updateAppConfig - Update SAML App Config
POST /saml/updateAppConfig - Update SAML App Config
- Request
- Response
POST /api/v1/saml/updateAppConfigHeaders:Organization Auth Configuration
Organization Auth Configuration
GET /orgAuthConfig/authMethods - Get Auth Methods
GET /orgAuthConfig/authMethods - Get Auth Methods
- Request
- Response
GET /api/v1/orgAuthConfig/authMethodsHeaders:POST /orgAuthConfig/updateAuthMethod - Update Auth Methods
POST /orgAuthConfig/updateAuthMethod - Update Auth Methods
- Request
- Response
POST /api/v1/orgAuthConfig/updateAuthMethodHeaders:- 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
samlSsocan only be used in a one-step configuration. A configuration with more than one step that includessamlSsoin any step is refused with400: “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
password- Username/password authenticationotp- One-time password via emailgoogle- Google OAuth authenticationmicrosoft- Microsoft OAuth authenticationazureAd- Azure Active Directory authenticationoauth- Generic OAuth authenticationsamlSso- SAML Single Sign-On
POST /orgAuthConfig/ - Setup Org Auth Config
POST /orgAuthConfig/ - Setup Org Auth Config
- Request
- Response
POST /api/v1/orgAuthConfig/Headers:Internal Endpoints
Internal Endpoints
GET /userAccount/internal/password/check - Check Password Method
GET /userAccount/internal/password/check - Check Password Method
- Request
- Response
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_EXPIRYenvironment variable (for example30m). 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/authenticateerror 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 alsoHTTP_UNAUTHORIZED(“Current password is incorrect.”). On/authenticate, a wrong password isHTTP_BAD_REQUESTinsteadHTTP_FORBIDDEN- Not allowed, for example an OAuth token without the required scopeHTTP_NOT_FOUND- Resource not foundVALIDATION_ERROR- The request body or parameters don’t match the expected formatINTERNAL_ERROR- A failure on PipesHub’s side; the message doesn’t describe internals
HTTP_BAD_REQUEST) or a wrong sign-in code (HTTP_UNAUTHORIZED), so that sign-in doesn’t reveal whether an account exists.
Important Notes
- Session Token Management: The
x-session-tokenheader is critical for multi-step authentication flows - Password Complexity: Passwords must meet minimum security requirements
- 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
- Token Scopes: Different endpoints require different token scopes for access
- Multi-Factor Authentication: Organizations can configure multiple authentication steps
- Provider Configuration: OAuth and SAML providers require proper configuration
- Email Validation: All email fields are validated for proper format
- Security Headers: Proper headers must be included for authentication flows