auth-api/docs/swagger.yaml

481 lines
12 KiB
YAML
Raw Normal View History

2021-06-22 22:52:48 +02:00
basePath: /
definitions:
db.Account:
properties:
created:
type: string
fields:
additionalProperties:
items:
type: string
type: array
type: object
id:
type: string
name:
type: string
type: object
2021-06-22 23:49:11 +02:00
db.AccountCreateInputFields:
properties:
name:
type: string
values:
items:
type: string
type: array
type: object
2021-06-22 22:52:48 +02:00
db.CreatedAccount:
properties:
apiKey:
type: string
id:
type: string
name:
type: string
type: object
2021-06-22 23:49:11 +02:00
handlers.AccountInput:
properties:
fields:
items:
$ref: '#/definitions/db.AccountCreateInputFields'
type: array
name:
type: string
password:
type: string
type: object
handlers.AuthInput:
properties:
name:
type: string
password:
type: string
type: object
2021-06-22 22:52:48 +02:00
handlers.ResJSONError:
properties:
error:
type: string
field:
type: string
type: object
2021-06-22 23:49:11 +02:00
handlers.ResToken:
properties:
jwt:
type: string
renewalToken:
type: string
type: object
2021-06-22 22:52:48 +02:00
info:
contact:
email: lilleman@larvit.se
name: Power Plan
2021-06-22 23:49:11 +02:00
url: https://pwrpln.com/
2021-06-22 22:52:48 +02:00
description: This is a tiny http API for auth. Register accounts, auth with api-key
or name/password, renew JWT tokens...
license:
name: MIT
title: JWT Auth API
version: "0.1"
paths:
2023-05-08 15:29:19 +02:00
/accounts:
get:
consumes:
- application/json
description: |-
Requires Authorization-header with role "admin".
Example: Authorization: bearer xxx
Where "xxx" is a valid JWT token
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/db.Account'
type: array
"401":
description: Unauthorized
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
"403":
description: Forbidden
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
"415":
description: Unsupported Media Type
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
"500":
description: Internal Server Error
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
summary: Get accounts
2021-06-22 22:52:48 +02:00
post:
consumes:
- application/json
2021-06-22 23:49:11 +02:00
description: |-
Requires Authorization-header with role "admin".
Example: Authorization: bearer xxx
Where "xxx" is a valid JWT token
2021-06-22 22:52:48 +02:00
operationId: account-create
2021-06-22 23:49:11 +02:00
parameters:
- description: Account object to be written to database
in: body
name: body
required: true
schema:
$ref: '#/definitions/handlers.AccountInput'
2021-06-22 22:52:48 +02:00
produces:
- application/json
responses:
2021-06-24 00:42:54 +02:00
"201":
description: Created
2021-06-22 22:52:48 +02:00
schema:
$ref: '#/definitions/db.CreatedAccount'
2021-06-24 00:42:54 +02:00
"400":
description: Bad Request
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
"401":
description: Unauthorized
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
"403":
description: Forbidden
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-24 00:42:54 +02:00
"409":
description: Conflict
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
"415":
description: Unsupported Media Type
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
"500":
description: Internal Server Error
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
summary: Create an account
2023-05-08 15:29:19 +02:00
/accounts/:id:
2021-06-24 00:42:54 +02:00
delete:
consumes:
- application/json
description: |-
2021-06-24 01:55:47 +02:00
Requires Authorization-header with role "admin" or a matching account id
2021-06-24 00:42:54 +02:00
Example: Authorization: bearer xxx
Where "xxx" is a valid JWT token
operationId: account-del
parameters:
- description: Account ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"204":
description: No Content
schema:
type: string
"400":
description: Bad Request
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
"401":
description: Unauthorized
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
"403":
description: Forbidden
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-24 01:55:47 +02:00
"404":
description: Not Found
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-24 00:42:54 +02:00
"415":
description: Unsupported Media Type
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
"500":
description: Internal Server Error
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
summary: Delete an account
2023-05-08 15:29:19 +02:00
/accounts/{id}:
2021-06-22 22:52:48 +02:00
get:
consumes:
- application/json
2021-06-22 23:49:11 +02:00
description: |-
Requires Authorization-header with either role "admin" or with a matching account id.
Example: Authorization: bearer xxx
Where "xxx" is a valid JWT token
2021-06-22 22:52:48 +02:00
operationId: get-account-by-id
parameters:
- description: Account ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/db.Account'
"401":
description: Unauthorized
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
"403":
description: Forbidden
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
"415":
description: Unsupported Media Type
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
"500":
description: Internal Server Error
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
summary: Get account by id
2023-05-08 15:29:19 +02:00
/accounts/{id}/fields:
2021-06-24 01:55:47 +02:00
put:
consumes:
- application/json
description: |-
Requires Authorization-header with role "admin".
Example: Authorization: bearer xxx
Where "xxx" is a valid JWT token
operationId: account-update-fields
parameters:
- description: Fields array with objects to be written to database
in: body
name: body
required: true
schema:
items:
$ref: '#/definitions/db.AccountCreateInputFields'
type: array
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/db.Account'
"400":
description: Bad Request
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
"401":
description: Unauthorized
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
"403":
description: Forbidden
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
"415":
description: Unsupported Media Type
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
"500":
description: Internal Server Error
schema:
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
summary: Update account fields
2021-06-22 22:52:48 +02:00
/auth/api-key:
post:
consumes:
- application/json
description: Authenticate account by API Key
operationId: auth-account-by-api-key
2021-06-22 23:49:11 +02:00
parameters:
- description: API Key as a string in JSON format (just encapsulate the string
with \
in: body
name: body
required: true
schema:
type: string
2021-06-22 22:52:48 +02:00
produces:
- application/json
responses:
"200":
description: OK
schema:
2021-06-22 23:49:11 +02:00
$ref: '#/definitions/handlers.ResToken'
2021-06-22 22:52:48 +02:00
"401":
description: Unauthorized
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
"403":
description: Forbidden
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
"415":
description: Unsupported Media Type
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
"500":
description: Internal Server Error
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
summary: Authenticate account by API Key
/auth/password:
post:
consumes:
- application/json
description: Authenticate account by Password
operationId: auth-account-by-password
2021-06-22 23:49:11 +02:00
parameters:
- description: Name and password to auth by
in: body
name: body
required: true
schema:
$ref: '#/definitions/handlers.AuthInput'
2021-06-22 22:52:48 +02:00
produces:
- application/json
responses:
"200":
description: OK
schema:
2021-06-22 23:49:11 +02:00
$ref: '#/definitions/handlers.ResToken'
2021-06-22 22:52:48 +02:00
"401":
description: Unauthorized
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
"403":
description: Forbidden
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
"415":
description: Unsupported Media Type
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
"500":
description: Internal Server Error
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
summary: Authenticate account by Password
/renew-token:
post:
consumes:
- application/json
description: Renew token
operationId: renew-token
2021-06-22 23:49:11 +02:00
parameters:
- description: Renewal token as a string in JSON format (just encapsulate the
string with \
in: body
name: body
required: true
schema:
type: string
2021-06-22 22:52:48 +02:00
produces:
- application/json
responses:
"200":
description: OK
schema:
2021-06-22 23:49:11 +02:00
$ref: '#/definitions/handlers.ResToken'
2021-06-22 22:52:48 +02:00
"401":
description: Unauthorized
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
"403":
description: Forbidden
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
"415":
description: Unsupported Media Type
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
"500":
description: Internal Server Error
schema:
2021-06-22 23:49:11 +02:00
items:
$ref: '#/definitions/handlers.ResJSONError'
type: array
2021-06-22 22:52:48 +02:00
summary: Renew token
swagger: "2.0"