Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Latest commit

 

History

History
67 lines (52 loc) · 1.21 KB

File metadata and controls

67 lines (52 loc) · 1.21 KB

@dsaidgovsg/swagger-ui-plugin-otp-auth

This is a OTP authentication plugin for Swagger UI.

Prerequisites

Install

Add github npm registry to .npmrc,

# .npmrc
always-auth = true
@dsaidgovsg:registry=https://npm.pkg.github.com

Install the package,

$ npm install @dsaidgovsg/swagger-ui-plugin-otp-auth

Usage

import OtpAuthPlugin from '@dsaidgovsg/swagger-ui-plugin-otp-auth'

// swagger-ui initialization
  SwaggerUI({
    plugins: [
      OtpAuthPlugin,
      ...
    ]
  })

Swagger Configuration

components:
  securitySchemes:
    OtpAuth:
      # base config
      type: http
      scheme: bearer
      otp: true
      # token url
      tokenUrl: /api/otp/
      # request path and method
      requestOtpPath: /new
      requestOtpMethod: post 
      requestOtpQuery:
        service: service-name
      # auth path and method
      authPath: /authenticate
      authMethod: post
      authQuery:
        service: service-name
        expiry: 10800

security:
  - OtpAuth: []