6 Commits

3 changed files with 20 additions and 13 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

@ -2,16 +2,14 @@ openapi: 3.0.0
info: info:
title: hv2-api title: hv2-api
version: "1" version: "1"
description: "REST-API for the nober.de Hausverwaltungs-Software" description: "REST-API for the Nober Grundbesitz GbR Hausverwaltungs-Software"
termsOfService: "https://home.hottis.de/dokuwiki/doku.php?id=hv2pub:termsofuse" termsOfService: "https://home.hottis.de/dokuwiki/doku.php?id=hv2pub:termsofuse"
contact: contact:
name: "Wolfgang Hottgenroth" name: "Wolfgang Hottgenroth"
email: "wolfgang.hottgenroth@icloud.com" email: "wolfgang.hottgenroth@icloud.com"
externalDocs: externalDocs:
description: "Find more details on this API here" description: "Find more details here"
url: "https://home.hottis.de/dokuwiki/doku.php?id=hv2pub:externaldocs" url: "https://home.hottis.de/dokuwiki/doku.php?id=hv2pub:externaldocs"
server:
url: "https://api.hv.nober.de/v1"
paths: paths:
/v1/test: /v1/test:
@ -23,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']
@ -37,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