4 Commits

3 changed files with 18 additions and 9 deletions

View File

@ -57,5 +57,5 @@ deploy:
- docker rm $CONTAINER_NAME || echo "$CONTAINER_NAME not exsting, anyway okay" - docker rm $CONTAINER_NAME || echo "$CONTAINER_NAME not exsting, anyway okay"
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY; - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY;
- docker pull $IMAGE_NAME:${CI_COMMIT_TAG} - docker pull $IMAGE_NAME:${CI_COMMIT_TAG}
- docker run -d --restart always --name "hv2-api" --network docker-server --ip 172.16.10.38 -v $SERVICE_VOLUME:/opt/app/config $IMAGE_NAME:${CI_COMMIT_TAG} - docker run -d --restart always --name $CONTAINER_NAME --network docker-server --ip 172.16.10.38 -v $SERVICE_VOLUME:/opt/app/config $IMAGE_NAME:${CI_COMMIT_TAG}

12
auth.py
View File

@ -2,7 +2,7 @@ from jose import JWTError, jwt
import werkzeug import werkzeug
import os import os
from loguru import logger from loguru import logger
import json
JWT_PUB_KEY = "" JWT_PUB_KEY = ""
try: try:
@ -19,9 +19,9 @@ def decodeToken(token):
logger.error("{}".format(e)) logger.error("{}".format(e))
raise werkzeug.exceptions.Unauthorized() raise werkzeug.exceptions.Unauthorized()
def testToken(user, token_info):
return '''
You are user_id {user} and the provided token has been signed by this issuers. Fine.'.
Decoded token claims: {token_info}.
'''.format(user=user, token_info=token_info)
def testToken(user, token_info):
return {
"message": f"You are user_id {user} and the provided token has been signed by this issuers. Fine.",
"details": json.dumps(token_info)
}

View File

@ -21,9 +21,9 @@ paths:
'200': '200':
description: secret response description: secret response
content: content:
'text/plain': 'application/json':
schema: schema:
type: string $ref: '#/components/schemas/TestOutput'
security: security:
- jwt: ['secret'] - jwt: ['secret']
@ -35,3 +35,12 @@ components:
scheme: bearer scheme: bearer
bearerFormat: JWT bearerFormat: JWT
x-bearerInfoFunc: auth.decodeToken x-bearerInfoFunc: auth.decodeToken
schemas:
TestOutput:
description: Test Output
type: object
properties:
message:
type: string
details:
type: string