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 or Microsoft 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: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
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: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
password- Username/password authenticationotp- One-time password via emailgoogle- Google OAuth authenticationmicrosoft- Microsoft OAuth authentication (includes Azure AD accounts)
samlSso, oauth or azureAd is refused with 400. samlSso and oauth sign-in were removed in PipesHub 1.0, and azureAd is now microsoft. Older saved policies are rewritten once when the server starts.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 wrong passwords or codes in a row
- The account owner is emailed when the block is applied
- A block lifts by itself after 24 hours, or an admin can unblock the account sooner
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)
Google and Microsoft Sign-In
- Tokens are validated against the provider
- Email verification ensures token authenticity
Error Handling
Errors use the API’s standard shape (status codes, error codes and rate limits are listed in Rate Limits and API Errors):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: At least 8 characters with an uppercase letter, a lowercase letter, a number and a special character, and at most 72 bytes
- 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: Google and Microsoft sign-in require provider credentials in the Authentication settings
- Email Validation: All email fields are validated for proper format
- Security Headers: Proper headers must be included for authentication flows