Complete the session deffinitions in the yml file.
This commit is contained in:
parent
f39ffedc87
commit
40bd435c22
@ -50,14 +50,119 @@ paths:
|
|||||||
- Session start
|
- Session start
|
||||||
summary: Starts an user session
|
summary: Starts an user session
|
||||||
operationId: session_start
|
operationId: session_start
|
||||||
description: Authenticate and initialize an user session in the api
|
description: Authentication and initialisation of a user session in the Api
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Authorized
|
description: Succeed
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/authorized'
|
$ref: '#/components/schemas/succeed'
|
||||||
|
headers:
|
||||||
|
token:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
description: Token expected in next operation header
|
||||||
|
example: '77e1c83b-7bb0-437b-bc50-a7a58e5660ac'
|
||||||
|
'403':
|
||||||
|
description: Unauthorized
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/unauthorized'
|
||||||
|
/v1.4/session/keep_alive:
|
||||||
|
put:
|
||||||
|
security:
|
||||||
|
- session_id: []
|
||||||
|
- token: []
|
||||||
|
- application_id: []
|
||||||
|
parameters:
|
||||||
|
- in: header
|
||||||
|
name: session_id
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
description: the Id of the current session
|
||||||
|
- in: header
|
||||||
|
name: token
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
description: the last token received from the API
|
||||||
|
- in: header
|
||||||
|
name: application_id
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
description: the Id of the application accessing this API
|
||||||
|
|
||||||
|
tags:
|
||||||
|
- Keep alive
|
||||||
|
summary: Keep the current user session alive
|
||||||
|
operationId: keep_alive
|
||||||
|
description: Refresh and keep the current session alive and renew the token
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Succeed
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/succeed'
|
||||||
|
headers:
|
||||||
|
token:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
description: Token expected in next operation header
|
||||||
|
example: '77e1c83b-7bb0-437b-bc50-a7a58e5660ac'
|
||||||
|
'403':
|
||||||
|
description: Unauthorized
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/unauthorized'
|
||||||
|
/v1.4/session/end:
|
||||||
|
put:
|
||||||
|
security:
|
||||||
|
- session_id: []
|
||||||
|
- token: []
|
||||||
|
- application_id: []
|
||||||
|
parameters:
|
||||||
|
- in: header
|
||||||
|
name: session_id
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
description: the Id of the current session
|
||||||
|
- in: header
|
||||||
|
name: token
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
description: the last token received from the API
|
||||||
|
- in: header
|
||||||
|
name: application_id
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
description: the Id of the application accessing this API
|
||||||
|
tags:
|
||||||
|
- End session
|
||||||
|
summary: Ends the current user session
|
||||||
|
operationId: session_end
|
||||||
|
description: End the current user session and free the alocated resources
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Succeed
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/succeed'
|
||||||
|
headers:
|
||||||
|
token:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
description: Token expected in next operation header
|
||||||
|
example: '77e1c83b-7bb0-437b-bc50-a7a58e5660ac'
|
||||||
'403':
|
'403':
|
||||||
description: Unauthorized
|
description: Unauthorized
|
||||||
content:
|
content:
|
||||||
@ -65,6 +170,19 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/unauthorized'
|
$ref: '#/components/schemas/unauthorized'
|
||||||
components:
|
components:
|
||||||
|
securitySchemes:
|
||||||
|
session_id:
|
||||||
|
type: apiKey
|
||||||
|
in: header
|
||||||
|
name: session_id
|
||||||
|
application_id:
|
||||||
|
type: apiKey
|
||||||
|
in: header
|
||||||
|
name: application_id
|
||||||
|
token:
|
||||||
|
type: apiKey
|
||||||
|
in: header
|
||||||
|
name: token
|
||||||
schemas:
|
schemas:
|
||||||
uptime:
|
uptime:
|
||||||
type: object
|
type: object
|
||||||
@ -72,21 +190,16 @@ components:
|
|||||||
uptime:
|
uptime:
|
||||||
type: string
|
type: string
|
||||||
format: hh:mm:ss.ms
|
format: hh:mm:ss.ms
|
||||||
example: "00:09:53.600281"
|
example: '00:09:53.600281'
|
||||||
authorized:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
session_id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
example: "ad0720ed-0f31-4f3e-9686-1177d4624ec1"
|
|
||||||
token:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
example: "660d1aa0-d24f-4cb1-902d-13c7bd29793c"
|
|
||||||
unauthorized:
|
unauthorized:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
error:
|
error:
|
||||||
type: string
|
type: string
|
||||||
example: "unauthorized"
|
example: 'unauthorized'
|
||||||
|
succeed:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
succeed:
|
||||||
|
type: string
|
||||||
|
example: 'OK'
|
@ -54,7 +54,7 @@ class SessionEnd(Resource):
|
|||||||
def put():
|
def put():
|
||||||
if remove_session(request):
|
if remove_session(request):
|
||||||
return Response(json.dumps({'result': 'succeed'}))
|
return Response(json.dumps({'result': 'succeed'}))
|
||||||
return Response(json.dumps({'error': 'invalid session'}), status=401)
|
return Response(json.dumps({'error': 'unauthorized'}), status=403)
|
||||||
|
|
||||||
class KeepSessionAlive(Resource):
|
class KeepSessionAlive(Resource):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -64,7 +64,7 @@ class KeepSessionAlive(Resource):
|
|||||||
def put():
|
def put():
|
||||||
session = refresh_session(request)
|
session = refresh_session(request)
|
||||||
if session is None:
|
if session is None:
|
||||||
return Response(json.dumps({'error': 'invalid session'}), status=401)
|
return Response(json.dumps({'error': 'unauthorized'}), status=403)
|
||||||
headers = session.headers
|
headers = session.headers
|
||||||
response = {'result': 'succeed'}
|
response = {'result': 'succeed'}
|
||||||
return Response(json.dumps(response), headers=headers)
|
return Response(json.dumps(response), headers=headers)
|
||||||
|
Loading…
Reference in New Issue
Block a user