diff --git a/app/api/routes/routes.py b/app/api/routes/routes.py index a88429b..816c65a 100644 --- a/app/api/routes/routes.py +++ b/app/api/routes/routes.py @@ -12,6 +12,14 @@ from app.api.services import ( from app.utils.logger import logger from app.api.middlewares import enforce_json, require_auth import os +from flask_jwt_extended import ( + JWTManager, + jwt_required, + create_access_token, + get_jwt_identity, + create_refresh_token, + jwt_refresh_token_required, +) api = Blueprint("api", __name__) @@ -123,8 +131,9 @@ def authorize(): # Authorize refresh endpoint @api.route("/AuthorizeRefresh", methods=["POST"]) +@jwt_refresh_token_required def refresh(): data = request.get_json() # logger.info(f"Authorize refresh request received: {data}") - response = AuthorizationService.process_refresh_request(data) + response = AuthorizationService.process_refresh_request() return response diff --git a/app/config.py b/app/config.py index 2329cee..6e1c431 100644 --- a/app/config.py +++ b/app/config.py @@ -1,4 +1,5 @@ import os +from datetime import timedelta class Config: @@ -24,6 +25,10 @@ class Config: SIMBRELLA_BASE_URL = os.getenv("SIMBRELLA_BASE_URL", "http://127.0.0.1:6337") JWT_SECRET_KEY = os.getenv("JWT_SECRET_KEY", "secret-key") + JWT_ACCESS_TOKEN_EXPIRES = os.getenv("JWT_ACCESS_TOKEN_EXPIRES", timedelta(hours=1)) + JWT_REFRESH_TOKEN_EXPIRES = os.getenv( + "JWT_REFRESH_TOKEN_EXPIRES", timedelta(days=30) + ) settings = Config() diff --git a/app/swagger/digifi_swagger.json b/app/swagger/digifi_swagger.json index bfc4128..2f15bd9 100644 --- a/app/swagger/digifi_swagger.json +++ b/app/swagger/digifi_swagger.json @@ -182,12 +182,18 @@ "basicAuth": { "type": "http", "scheme": "basic" + }, + "bearerAuth": { + "type": "http", + "scheme": "bearer", + "bearerFormat": "JWT" } } }, "security": [ { - "basicAuth": [] + "basicAuth": [], + "bearerAuth": [] } ] } diff --git a/app/swagger/schemas/AuthorizeRefreshRequest.json b/app/swagger/schemas/AuthorizeRefreshRequest.json index 7221fab..bdee421 100644 --- a/app/swagger/schemas/AuthorizeRefreshRequest.json +++ b/app/swagger/schemas/AuthorizeRefreshRequest.json @@ -1,11 +1,6 @@ { "type": "object", - "properties": { - "access_token": { - "type": "string", - "example": "access_token" - } - }, + "properties": {}, "xml": { "name": "AuthorizeRefreshRequest" }