160 lines
4.6 KiB
YAML
160 lines
4.6 KiB
YAML
openapi: 3.1.1
|
|
info:
|
|
title: Auth Service
|
|
version: 1.0.0
|
|
|
|
servers:
|
|
- url: /auth
|
|
|
|
paths:
|
|
/auth/sign-up:
|
|
post:
|
|
summary: Sign up a new user
|
|
tags: [Auth]
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required: [nickname, pass]
|
|
properties:
|
|
nickname:
|
|
type: string
|
|
pass:
|
|
type: string
|
|
format: password
|
|
responses:
|
|
"200":
|
|
description: Sign-up result
|
|
content:
|
|
application/json:
|
|
schema:
|
|
required:
|
|
- user_id
|
|
type: object
|
|
properties:
|
|
user_id:
|
|
type: integer
|
|
format: int64
|
|
|
|
/auth/sign-in:
|
|
post:
|
|
summary: Sign in a user and return JWT
|
|
tags: [Auth]
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required: [nickname, pass]
|
|
properties:
|
|
nickname:
|
|
type: string
|
|
pass:
|
|
type: string
|
|
format: password
|
|
responses:
|
|
# This one also sets two cookies: access_token and refresh_token
|
|
"200":
|
|
description: Sign-in result with JWT
|
|
content:
|
|
application/json:
|
|
schema:
|
|
required:
|
|
- user_id
|
|
- user_name
|
|
type: object
|
|
properties:
|
|
user_id:
|
|
type: integer
|
|
format: int64
|
|
user_name:
|
|
type: string
|
|
"401":
|
|
description: Access denied due to invalid credentials
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
error:
|
|
type: string
|
|
example: "Access denied"
|
|
# /auth/verify-token:
|
|
# post:
|
|
# summary: Verify JWT validity
|
|
# tags: [Auth]
|
|
# requestBody:
|
|
# required: true
|
|
# content:
|
|
# application/json:
|
|
# schema:
|
|
# type: object
|
|
# required: [token]
|
|
# properties:
|
|
# token:
|
|
# type: string
|
|
# description: JWT token to validate
|
|
# responses:
|
|
# "200":
|
|
# description: Token validation result
|
|
# content:
|
|
# application/json:
|
|
# schema:
|
|
# type: object
|
|
# properties:
|
|
# valid:
|
|
# type: boolean
|
|
# description: True if token is valid
|
|
# user_id:
|
|
# type: string
|
|
# nullable: true
|
|
# description: User ID extracted from token if valid
|
|
# error:
|
|
# type: string
|
|
# nullable: true
|
|
# description: Error message if token is invalid
|
|
# /auth/refresh-token:
|
|
# post:
|
|
# summary: Refresh JWT using a refresh token
|
|
# tags: [Auth]
|
|
# requestBody:
|
|
# required: true
|
|
# content:
|
|
# application/json:
|
|
# schema:
|
|
# type: object
|
|
# required: [refresh_token]
|
|
# properties:
|
|
# refresh_token:
|
|
# type: string
|
|
# description: JWT refresh token obtained from sign-in
|
|
# responses:
|
|
# "200":
|
|
# description: New access (and optionally refresh) token
|
|
# content:
|
|
# application/json:
|
|
# schema:
|
|
# type: object
|
|
# properties:
|
|
# valid:
|
|
# type: boolean
|
|
# description: True if refresh token was valid
|
|
# user_id:
|
|
# type: string
|
|
# nullable: true
|
|
# description: User ID extracted from refresh token
|
|
# access_token:
|
|
# type: string
|
|
# description: New access token
|
|
# nullable: true
|
|
# refresh_token:
|
|
# type: string
|
|
# description: New refresh token (optional)
|
|
# nullable: true
|
|
# error:
|
|
# type: string
|
|
# nullable: true
|
|
# description: Error message if refresh token is invalid
|