Skip to content

Authentication API

DRAFT — Internal Developer Use Only

This API reference is for internal development teams.

Overview

What it is: The authentication API provides token-based access to all Discovery endpoints. Three methods are available depending on the integration type.

Why it matters: Every API call requires a valid token. Service-to-service integrations like Hydden Control use API credentials, while interactive sessions may use OTP or OAuth.

Endpoints

Token Generation

MethodPathDescriptionAuth required
POST/auth/apiAuthenticate with API credentialsNone (credentials in body)
POST/auth/otpAuthenticate with one-time passwordNone (credentials in body)
POST/oauth/tokenOAuth 2.0 token endpointBasic Auth header

Token Management

MethodPathDescriptionAuth required
GET/internal/v1/token/renewRenew an expiring access tokenJWT cookie
GET/internal/v1/user/infoGet current authenticated user infoJWT cookie
GET/internal/v1/versionGet API versionJWT cookie
GET/internal/v1/featuresGet enabled feature flagsJWT cookie

OIDC Provider Management

MethodPathDescriptionAuth required
GET/internal/v1/oidc/providersList OIDC providersJWT cookie
GET/internal/v1/oidc/registrationGet registration statusJWT cookie
POST/internal/v1/oidc/registration/acceptAccept OIDC registrationJWT cookie
POST/internal/v1/oidc/registration/rejectReject OIDC registrationJWT cookie
GET/internal/v1/oidc/registration/joinOIDC registration join flowJWT cookie

Access Control

MethodPathDescriptionAuth required
GET/internal/v1/access/roleGet current user role and permissionsJWT cookie
GET/internal/v1/access/role/*actionCheck permission for a specific actionJWT cookie

Nonce

MethodPathDescriptionAuth required
GET/auth/nonce/:nonceRetrieve a nonce valueNone
POST/auth/nonceCreate a new nonceNone

POST /auth/api

Authenticate with API client credentials. This is the primary method for service-to-service communication.

Request:

http
POST /auth/api
Content-Type: application/json

{
  "id": "your-client-id",
  "secret": "your-client-secret",
  "code": "optional-tenant-code"
}

Response (200):

json
{
  "accessToken": "eyJhbGciOiJSUzI1NiIs...",
  "expiresIn": 3600,
  "tokenType": "Bearer"
}

Error responses:

CodeReason
401Invalid credentials
403Client disabled or tenant mismatch

Control Integration

Hydden Control authenticates using this endpoint. The HTTPClient sends ClientID and ClientSecret from encrypted integration settings:

go
// Control's authentication flow (simplified)
POST {DiscoveryBaseURL}/auth/api
Body: {"id": clientID, "secret": decryptedSecret}

// Token is cached per tenant with TTL from expiresIn
// Automatic retry with exponential backoff on 429/5xx

Control caches tokens per tenant and refreshes them before expiry. The token cache uses a read-write mutex for thread safety.


POST /auth/otp

Authenticate with a one-time password.

Request:

http
POST /auth/otp
Content-Type: application/json

{
  "id": "user-identifier",
  "secret": "otp-secret",
  "code": "one-time-code"
}

Response: Same format as /auth/api.


POST /oauth/token

Standard OAuth 2.0 token endpoint. Supports Basic Auth header for client credentials.

Request:

http
POST /oauth/token
Authorization: Basic base64(client_id:client_secret)
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials

Response (200):

json
{
  "access_token": "eyJhbGciOiJSUzI1NiIs...",
  "token_type": "Bearer",
  "expires_in": 3600
}

GET /internal/v1/token/renew

Renew the current access token before it expires. Requires an active JWT cookie session.

Request:

http
GET /internal/v1/token/renew
Cookie: jwt=<current-token>

Response (200):

json
{
  "accessToken": "eyJhbGciOiJSUzI1NiIs...",
  "expiresIn": 3600
}

GET /internal/v1/user/info

Get information about the currently authenticated user.

Request:

http
GET /internal/v1/user/info
Authorization: Bearer <token>

Response (200):

json
{
  "userId": "user-uuid",
  "email": "user@example.com",
  "role": "admin",
  "tenantId": "tenant-uuid"
}

Hydden Documentation and Training Hub