Auth & Identities

Authentication endpoints and identity management in the Novacore REST API.

Authentication Endpoints

Request Challenge

POST /auth/challenge

Request a challenge string to sign for authentication.

Request Body:

{
  "public_key": "base64-encoded-public-key"
}

Response:

{
  "challenge": "random-challenge-string",
  "expires_at": "2026-03-06T13:00:00Z"
}

Verify Signature

POST /auth/verify

Submit the signed challenge to receive a JWT token.

Request Body:

{
  "public_key": "base64-encoded-public-key",
  "signature": "base64-encoded-signature",
  "challenge": "the-challenge-string"
}

Response:

{
  "token": "eyJhbGciOiJIUzI1NiIs...",
  "identity_id": "usr-abc123"
}

Identity Types

TypeKey AlgorithmDescription
rootEd25519System administrator
adminEd25519Platform administrator
userEd25519Human user (developer, operator)
gatewayES256Zap gateway device
deviceES256Smart device with direct connectivity
integrationES256Third-party service (monitoring)
developerEd25519API developer
internalES256Internal service

Identity Registration

Register a new identity before first authentication:

POST /identity/register

Request Body:

{
  "public_key": "base64-encoded-public-key"
}

Knowledge gap for Johan: What fields does identity registration require beyond public_key? Is registration required before /auth/challenge, or does the challenge endpoint auto-register new keys? What is the full response from registration?

OAuth2 (For Integrations)

Novacore supports OAuth2 Authorization Code flow for integrations like Grafana:

EndpointDescription
GET /oauth/authorizeAuthorization page
POST /oauth/authorize/completeComplete authorization
POST /oauth/tokenExchange code for token
GET /oauth/userinfoGet authenticated user info

OAuth2 is primarily for internal integrations. External developer applications should use the challenge/verify flow.

MQTT Authentication (Gateways)

Gateways authenticate to NATS/MQTT using ES256 JWTs. This is handled internally by the auth-callout service:

Internal EndpointDescription
POST /internal/mqtt/authValidate MQTT connection credentials
POST /internal/mqtt/aclCheck topic-level access control

These endpoints are not for external use — they're called by the NATS auth-callout service during gateway connection.