App Connect

Integrate custom applications with Navixy authentication

Navixy App Connect is an authentication gateway that enables you to build custom applications integrating with Navixy without implementing your own user management system. Users authenticate once through their Navixy account, and your application receives secure database access credentials automatically.

The middleware acts as an authentication proxy that:

  1. Authenticates users via their session_key

  2. Fetches database credentials from the master database

  3. Calls your application's auth endpoint with user info and database URLs

  4. Proxies all subsequent requests to your application

Common use cases:

  • Custom dashboards for IoT data visualization

  • Analytics tools processing telemetry data

  • Business system integrations with Navixy data

Dashboard Studio uses this authentication approach. You can integrate any custom application the same way.

Your application must implement a specific auth endpoint and handle JWT tokens according to this contract.

Required API Endpoint

POST /api/auth/login

Your application must implement this endpoint to receive authentication requests from the middleware.

Request

Request Body:

Field
Type
Description

email

string

User's email address from the session

iotDbUrl

string

PostgreSQL connection string for IoT database (role ending with user)

userDbUrl

string

PostgreSQL connection string for user database (role ending with _dashboard_studio)

role

string

User role (default: admin, configurable via DEFAULT_ROLE env)

Response

Success Response (200 OK):

Field
Type
Description

success

boolean

Must be true for successful authentication

user.id

string

Unique user identifier (UUID recommended)

user.email

string

User's email address

user.role

string

User's role

token

string

JWT token for subsequent API requests

Error Response (4xx/5xx):

JWT Token Requirements

Token Creation

Your application must generate a JWT token with the following payload structure:

Field
Type
Required
Description

userId

string

Yes

Unique user identifier

email

string

Yes

User's email address (used for session validation)

role

string

Yes

User's role

iat

number

Yes

Issued at timestamp (Unix seconds)

exp

number

Yes

Expiration timestamp (Unix seconds)

Token Signing

  • Use HS256 (HMAC-SHA256) or RS256 (RSA-SHA256) algorithm

  • Recommended expiration: 24 hours (exp = iat + 86400)

  • The middleware does not verify the token signature; it only decodes and checks expiration

Token Validation by Middleware

The middleware validates tokens by:

  1. Expiration Check: Token exp must be in the future (with 30-second buffer)

  2. Email Match: Token email must match the session user's email (case-insensitive)

Token Storage (Client-Side)

The middleware stores the JWT token in the browser's localStorage:

Storage Key

Key
Value

auth_token

JWT token string

API Request Authorization

For /api/* Routes

All requests to paths starting with /api/ will include the JWT token as a Bearer token:

Your API endpoints should:

  1. Extract the Bearer token from the Authorization header

  2. Verify the token signature (using your secret key)

  3. Check token expiration

  4. Use the decoded payload for user identification

Example (Node.js/Express):

For Static Assets and Other Routes

Non-API routes (HTML, CSS, JS, images) are proxied with Basic Authentication from the middleware's environment:

This is configured via the DASHBOARD_BASIC_AUTH environment variable in the middleware.

Using Database Connection Strings

IoT Database URL (iotDbUrl)

The iotDbUrl provides a PostgreSQL connection string for the IoT database with a role that has read access to IoT data.

Format:

Example usage (Node.js with pg):

User Database URL (userDbUrl)

The userDbUrl provides a PostgreSQL connection string for user-specific data with Dashboard Studio role permissions.

Example usage:

Security Considerations

  • Never expose database URLs to the client/browser

  • Store connection URLs securely in server memory or encrypted storage

  • Use connection pooling to manage database connections efficiently

  • Consider setting connection timeouts to prevent resource exhaustion

Complete Integration Example

1

Implement Auth Endpoint

2

Protect API Routes

3

Use Database Connections

Checklist

Before integrating with App Connect, ensure your application:

Troubleshooting

"Token does not match current session"

This error occurs when the email in the cached JWT token doesn't match the email of the current session user. This typically happens when:

  • A different user logs in on the same browser

  • The session expired and a new session was created

Solution: The middleware automatically handles this by removing the old token and requesting fresh authentication.

"Authentication failed"

The middleware received a non-success response from your /api/auth/login endpoint.

Check:

  • Your endpoint returns { success: true, ... } on success

  • Your endpoint returns a valid JWT in the token field

  • Your endpoint doesn't throw unhandled errors

API requests return 401

Check:

  • The client is sending the Authorization: Bearer <token> header

  • Your API middleware correctly extracts and verifies the token

  • The token hasn't expired

Version History

Version
Date
Changes

1.0

2025-12-23

Initial contract documentation

Last updated

Was this helpful?