Skip to main content

Overview

MagenX404 uses a challenge-response authentication system where users sign a challenge with their Solana wallet to prove ownership.

Authentication Flow

Step 1: Request Nonce

Make a GET request to any endpoint without authentication headers:
The server responds with:

Step 2: Build Challenge Payload

Construct the challenge payload:
Where:
  • nonce: The nonce from the X-404-Nonce header
  • path: The API path (e.g., /x404_auth/blacklist)
  • feature: The feature constant (e.g., SENTINEL404_BLACKLIST)

Step 3: Sign with Wallet

Sign the payload using the user’s Solana wallet:

Step 4: Send Authenticated Request

Send the request with authentication headers:

Step 5: Receive JWT Token

On success, the server returns a JWT token:

Re-authentication

For subsequent requests, you can use the JWT token instead of signing again:
The server will verify the JWT and return success if valid.

Implementation Example

Here’s a complete example using the client library:

Manual Implementation

If implementing manually:

Security Considerations

  1. Nonce Expiration: Nonces expire after a short period (typically 5 minutes)
  2. Signature Verification: Server verifies the signature matches the public key
  3. JWT Expiration: JWT tokens have expiration times (typically 30 days)
  4. Replay Protection: Nonces can only be used once

Error Handling

Common authentication errors: