Skip to content

curityio/mock-backend-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Mock API for Polling Authenticator

This is a mock backend API to simulate a user-driven approval flow used by a custom polling authenticator in the Curity Identity Server.

The API simulates sending a notification to a user, tracking their decision (approve/decline), and allowing the polling-example-authenticator to poll for the user's response.


Features

  • POST /send-notification: Simulates sending an authentication request to a user
  • GET /status/:requestId: Returns the current status of the request
  • POST /user-action: Allows a user to approve or decline a request

Prerequisites

  • Node.js (v18+ recommended)
  • npm or yarn

Setup

  1. Clone the repository
  2. Install dependencies (only express and uuid are required):
npm install
  1. Start the server
node mock-api.js

The API will start on http://localhost:3000.


API Endpoints

POST /send-notification

Simulates triggering a notification for a user to approve or decline.

Request Body:

{
  "username": "alice"
}

Response:

{
  "requestId": "140896ed-a726-43e0-a359-d0f1f7bbedc2"
}

GET /status/:requestId

Polls the current status of a specific request.

Response:

{
  "status": "pending"
}

Status can be:

  • pending
  • approved
  • declined

POST /user-action

Simulates a user approving or declining the request.

Request Body:

{
  "requestId": "140896ed-a726-43e0-a359-d0f1f7bbedc2",
  "action": "approve"
}

Valid actions:

  • approve
  • decline

Example Flow

  1. Call POST /send-notification with a username
  2. Poll GET /status/:requestId from your authenticator
  3. Simulate the user's action by calling POST /user-action with approve or decline
  4. Authenticator receives the updated status during polling

Notes

  • This is a mock/stub implementation meant for testing the polling authenticator plugin.
  • No persistence: all statuses are stored in-memory.
  • No authentication or security is implemented.

About

Mock backend API to simulate a user-driven approval flow used by a custom polling authenticator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published