mCaptcha/openapi.yaml

796 lines
19 KiB
YAML
Raw Normal View History

2021-03-30 18:19:09 +03:00
openapi: 3.0.0
info:
version: 0.1.0
title: mCaptcha/guard
servers:
2021-03-31 09:55:39 +03:00
- url: /
2021-03-30 18:19:09 +03:00
paths:
/api/v1/signup:
post:
2021-03-31 09:55:39 +03:00
summary: Registration endpoint
2021-03-30 18:19:09 +03:00
operationId: registerUser
tags:
- user
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RegisterUser'
2021-03-31 12:57:23 +03:00
example:
2021-04-11 20:29:35 +03:00
username: 'testuser'
password: 'mysuperlongandsecurepassword'
email: 'testuser@example.com'
2021-03-30 18:19:09 +03:00
responses:
'200':
2021-03-31 09:55:39 +03:00
description: Successful registration
'400':
description: >-
Bad request: username contains profainity/blacklisted words or email
not acceptable or password too long/short or duplicate
username/password
2021-03-30 18:19:09 +03:00
content:
application/json:
schema:
2021-03-31 09:55:39 +03:00
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
2021-03-30 18:19:09 +03:00
content:
2021-03-31 09:55:39 +03:00
application/json:
schema:
$ref: '#/components/schemas/Error'
2021-03-30 18:19:09 +03:00
/api/v1/signin:
post:
2021-03-31 09:55:39 +03:00
summary: Login endpoint
2021-03-30 18:19:09 +03:00
operationId: loginUser
tags:
- user
- authentication
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/LoginUser'
2021-03-31 12:57:23 +03:00
example:
2021-04-11 20:29:35 +03:00
username: 'testuser'
password: 'mysuperlongandsecurepassword'
2021-03-30 18:19:09 +03:00
responses:
'200':
2021-03-31 09:55:39 +03:00
description: Successful authentication
2021-03-30 18:19:09 +03:00
'401':
description: 'authentication failed, wrong password'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
2021-03-31 09:55:39 +03:00
description: username not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
2021-03-30 18:19:09 +03:00
/api/v1/signout:
post:
security:
- cookieAuth: []
2021-03-31 09:55:39 +03:00
summary: Signout endpoint
2021-03-30 18:19:09 +03:00
operationId: signoutUser
tags:
- user
- authentication
responses:
'200':
2021-03-31 09:55:39 +03:00
description: OK
2021-03-30 18:19:09 +03:00
/api/v1/account/delete:
post:
2021-03-31 11:02:40 +03:00
security:
- cookieAuth: []
summary: Delete account
operationId: deleteAccount
2021-03-30 18:19:09 +03:00
tags:
- user
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/DeleteUser'
2021-03-31 12:57:23 +03:00
example:
2021-04-11 20:29:35 +03:00
password: 'mysuperlongandsecurepassword'
2021-03-30 18:19:09 +03:00
responses:
'200':
2021-03-31 09:55:39 +03:00
description: OK
'401':
description: (cookie)authentication required or wrong password
2021-03-30 18:19:09 +03:00
content:
application/json:
schema:
2021-03-31 09:55:39 +03:00
$ref: '#/components/schemas/Error'
'404':
description: username not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
2021-03-30 18:19:09 +03:00
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/v1/account/username/exists:
post:
2021-03-31 09:55:39 +03:00
summary: Check if username exists
2021-03-30 18:19:09 +03:00
operationId: usernameExists
tags:
- user
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserDetailCheck'
2021-03-31 12:57:23 +03:00
example:
2021-04-11 20:29:35 +03:00
val: 'testuser'
2021-03-30 18:19:09 +03:00
responses:
'200':
2021-03-31 09:55:39 +03:00
description: OK
2021-03-30 18:19:09 +03:00
content:
application/json:
schema:
2021-03-31 09:55:39 +03:00
$ref: '#/components/schemas/UserDetailCheckRes'
2021-03-30 18:19:09 +03:00
'500':
2021-03-31 09:55:39 +03:00
description: Internal server error
2021-03-30 18:19:09 +03:00
content:
application/json:
schema:
2021-03-31 09:55:39 +03:00
$ref: '#/components/schemas/Error'
2021-03-30 18:19:09 +03:00
/api/v1/account/email/exists:
post:
2021-03-31 09:55:39 +03:00
summary: Check if email exists
2021-03-30 18:19:09 +03:00
operationId: emailExists
tags:
- user
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserDetailCheck'
2021-03-31 12:57:23 +03:00
example:
2021-04-11 20:29:35 +03:00
val: 'testuser@example.com'
2021-03-30 18:19:09 +03:00
responses:
'200':
2021-03-31 09:55:39 +03:00
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/UserDetailCheckRes'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/v1/meta/health:
get:
summary: Health check
operationId: healthCheck
tags:
- meta
- health
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Health'
/api/v1/meta/build:
get:
summary: Get server binary build details
operationId: buildDetails
tags:
- meta
- build
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/BuildDetails'
2021-03-31 10:35:33 +03:00
/api/v1/mcaptcha/domain/token/add:
post:
security:
- cookieAuth: []
summary: Add token for registered domain
operationId: addToken
tags:
- mcaptcha
- domain
- token
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/MCaptchaID'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/MCaptchaDetails'
'400':
2021-03-31 11:02:40 +03:00
description: 'Bad request: Submited URI is not a URI or duplicate token name'
2021-03-31 10:35:33 +03:00
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: 'authentication failed'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/v1/mcaptcha/domain/token/update:
post:
security:
- cookieAuth: []
summary: Update token key
operationId: updateTokenKey
tags:
- mcaptcha
- domain
- token
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/MCaptchaID'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/MCaptchaDetails'
'400':
2021-03-31 11:02:40 +03:00
description: 'Bad request: Submited URI is not a URI or duplicate token name'
2021-03-31 10:35:33 +03:00
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: 'authentication failed'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/v1/mcaptcha/domain/token/get:
post:
security:
- cookieAuth: []
summary: Get token key
operationId: getTokenKey
tags:
- mcaptcha
- domain
- token
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/MCaptchaID'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/MCaptchaDetails'
'400':
2021-03-31 11:02:40 +03:00
description: 'Bad request: Submited URI is not a URI'
2021-03-31 10:35:33 +03:00
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: 'authentication failed'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: token name not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/v1/mcaptcha/domain/token/delete:
post:
security:
- cookieAuth: []
2021-03-31 11:02:40 +03:00
summary: Delete token from mcaptcha
operationId: deleteToken
2021-03-31 10:35:33 +03:00
tags:
- mcaptcha
- domain
2021-03-31 11:02:40 +03:00
- token
2021-03-31 10:35:33 +03:00
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/MCaptchaID'
responses:
'200':
description: OK
'401':
description: 'authentication failed'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
2021-03-31 11:02:40 +03:00
/api/v1/mcaptcha/domain/token/levels/add:
post:
security:
- cookieAuth: []
summary: Add levels to a token
operationId: addTokenLevels
tags:
- mcaptcha
- domain
- token
- levels
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AddLevels'
responses:
'200':
description: OK
'400':
description: 'duplicate visitor count or difficulty_factor is zero or difficulty_factor decreases with increase in visitor count'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: 'authentication failed'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/v1/mcaptcha/domain/token/levels/update:
post:
security:
- cookieAuth: []
summary: Update levels of a token
operationId: updateTokenLevels
tags:
- mcaptcha
- domain
- token
- levels
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AddLevels'
2021-03-31 10:35:33 +03:00
2021-03-31 11:02:40 +03:00
responses:
'200':
description: OK
'400':
description: 'duplicate visitor count or difficulty_factor is zero or difficulty_factor decreases with increase in visitor count'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: 'authentication failed'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/v1/mcaptcha/domain/token/levels/delete:
post:
security:
- cookieAuth: []
tags:
- mcaptcha
- domain
- token
- levels
summary: Delete levels of a token
operationId: deleteTokenLevels
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AddLevels'
responses:
'200':
description: OK
'401':
description: (cookie)authentication required or wrong password
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/v1/mcaptcha/domain/token/levels/get:
post:
security:
- cookieAuth: []
tags:
- mcaptcha
- domain
- token
- levels
summary: Get levels of a token
operationId: getTokenLevels
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AddLevels'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Levels'
'401':
description: (cookie)authentication required or wrong password
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
2021-03-31 11:26:55 +03:00
/api/v1/mcaptcha/domain/token/token/get:
post:
security:
- cookieAuth: []
tags:
- mcaptcha
- domain
- token
- levels
- duration
summary: Get duration of a token
operationId: getTokenDuration
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/GetDuration'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Duration'
'401':
description: (cookie)authentication required or wrong password
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/v1/mcaptcha/domain/token/token/update:
post:
security:
- cookieAuth: []
tags:
- mcaptcha
- domain
- token
- levels
- duration
summary: update duration of a token
operationId: updateTokenDuration
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateDuration'
responses:
'200':
description: OK
'400':
description: 'Bad request: Duration must be greater than 0'
'401':
description: (cookie)authentication required or wrong password
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
2021-03-30 18:19:09 +03:00
components:
schemas:
RegisterUser:
type: object
required:
- username
- password
- email
properties:
username:
type: string
email:
type: string
password:
type: string
format: password
LoginUser:
type: object
required:
- username
- password
properties:
username:
type: string
password:
2021-03-31 09:55:39 +03:00
type: string
2021-03-30 18:19:09 +03:00
format: password
DeleteUser:
type: object
required:
- password
properties:
password:
2021-03-31 09:55:39 +03:00
type: string
2021-03-30 18:19:09 +03:00
format: password
Error:
type: object
required:
- error
properties:
error:
type: string
User:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
UserDetailCheck:
type: object
required:
- val
properties:
val:
type: string
2021-03-31 09:55:39 +03:00
Health:
type: object
required:
- db
properties:
db:
type: boolean
2021-03-30 18:19:09 +03:00
UserDetailCheckRes:
type: object
required:
2021-03-31 09:55:39 +03:00
- exists
properties:
val:
type: boolean
BuildDetails:
type: object
required:
- version
- git_commit_hash
properties:
version:
type: string
git_commit_hash:
type: string
AddDomain:
type: object
required:
- name
properties:
name:
type: string
DomainVerificationChallenge:
type: object
required:
- verification_challenge
2021-03-30 18:19:09 +03:00
properties:
2021-03-31 09:55:39 +03:00
verification_challenge:
type: string
2021-03-31 10:35:33 +03:00
MCaptchaID:
type: object
required:
- name
- domain
properties:
name:
type: string
domain:
type: string
MCaptchaDetails:
type: object
required:
- name
- key
properties:
name:
type: string
key:
type: string
2021-03-31 11:02:40 +03:00
Level:
type: object
required:
- visitor_threshold
- difficulty_factor
properties:
visitor_threshold:
type: number
minimum: 1
maximum: 2147483647
difficulty_factor:
type: number
minimum: 1
GetLevels:
type: object
required:
- token
properties:
token:
type: string
Levels:
type: array
items:
$ref: '#/components/schemas/Level'
AddLevels:
type: object
required:
- name
- levels
properties:
name:
type: string
levels:
type: array
items:
$ref: '#/components/schemas/Level'
2021-03-31 11:26:55 +03:00
GetDuration:
type: object
required:
- token
properties:
token:
type: string
Duration:
type: object
required:
- duration
properties:
duration:
type: number
minimum: 1
maximum: 2147483647
UpdateDuration:
type: object
required:
- duration
- token_name
properties:
token_name:
type: string
duration:
type: number
minimum: 1
maximum: 2147483647
2021-03-30 18:19:09 +03:00
securitySchemes:
cookieAuth:
type: apiKey
in: cookie
name: Authorization