SoCMate supports three authentication methods: OAuth2 Authorization Code flow for interactive users, API keys for simple machine integrations, and OAuth2 Client Credentials for service-to-service communication.

OAuth2 Authorization Code Flow

This is the primary authentication method for browser-based users. SoCMate uses Azure Entra ID (formerly Azure AD) as the identity provider.
1

Initiate login

Request an authorization URL from the API:
Response:
2

User authenticates

Redirect the user to the auth_url. They authenticate with Azure Entra ID and complete MFA if required. Azure redirects back to your redirect_uri with an authorization code:
3

Exchange code for tokens

Send the authorization code to the API:
Response:
The response also sets three httpOnly cookies:
  • access_token — JWT for API authorization
  • refresh_token — token for renewal
  • token_expiry — expiration timestamp (readable by client-side JavaScript)
4

Make authenticated requests

Subsequent requests include the JWT automatically via cookies, or you can pass it as a Bearer token:

Token Refresh

Access tokens expire after a configurable period (default: 30 minutes). Use the refresh endpoint to obtain new tokens:
Response:
The response sets updated cookies with new token values. The token_expiry cookie (not httpOnly) can be read by client-side JavaScript to proactively refresh before expiration.
The SoCMate UI automatically handles token refresh. If you are building a custom integration, check the token_expiry cookie and refresh the token before it expires.

API Key Authentication

API keys provide a simpler authentication method for automated integrations, scripts, and CI/CD pipelines. They do not require the OAuth2 flow.

Using an API Key

Pass the API key in the X-API-Key header:

API Key Scopes

Each API key is scoped to specific permissions: A request to an endpoint outside the key’s scopes returns 403 Forbidden.

Key Format

API keys follow the format sk_live_{key_id}{random_secret}. The key_id prefix is visible in the admin panel and in API responses; the full key is only shown once at creation time.
Store your API key securely. The full key is only displayed once when created or rotated. SoCMate stores only a salted hash of the key. If you lose the key, you must rotate it to generate a new one.

OAuth2 Client Credentials Flow

For service-to-service integrations (SOAR platforms, ticketing systems, custom automation), use the OAuth2 Client Credentials flow.
1

Create an API Client

An admin creates an API client in the SoCMate Admin panel. See API Clients for details.
2

Request an access token

Response:
3

Use the token

When using the browser-based OAuth2 flow, tokens are stored in cookies with the following security settings:
  • httpOnly prevents JavaScript from reading the token (XSS protection)
  • Secure ensures cookies are only sent over HTTPS
  • SameSite=Lax prevents CSRF for most cross-site requests
  • token_expiry is intentionally not httpOnly so the UI can check if a refresh is needed

User Info

Retrieve the authenticated user’s profile:
Response:

Roles and Permissions

SoCMate uses role-based access control (RBAC) with two roles: New users are assigned the analyst role on first login. Admins can promote users via the Admin panel.

Logout

Clear the authentication session:
This clears all authentication cookies and invalidates the session.