progress on JWT
This commit is contained in:
@@ -12,6 +12,14 @@ from app.api.services import (
|
|||||||
from app.utils.logger import logger
|
from app.utils.logger import logger
|
||||||
from app.api.middlewares import enforce_json, require_auth
|
from app.api.middlewares import enforce_json, require_auth
|
||||||
import os
|
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__)
|
api = Blueprint("api", __name__)
|
||||||
@@ -123,8 +131,9 @@ def authorize():
|
|||||||
|
|
||||||
# Authorize refresh endpoint
|
# Authorize refresh endpoint
|
||||||
@api.route("/AuthorizeRefresh", methods=["POST"])
|
@api.route("/AuthorizeRefresh", methods=["POST"])
|
||||||
|
@jwt_refresh_token_required
|
||||||
def refresh():
|
def refresh():
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
# logger.info(f"Authorize refresh request received: {data}")
|
# logger.info(f"Authorize refresh request received: {data}")
|
||||||
response = AuthorizationService.process_refresh_request(data)
|
response = AuthorizationService.process_refresh_request()
|
||||||
return response
|
return response
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
@@ -24,6 +25,10 @@ class Config:
|
|||||||
SIMBRELLA_BASE_URL = os.getenv("SIMBRELLA_BASE_URL", "http://127.0.0.1:6337")
|
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_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()
|
settings = Config()
|
||||||
|
|||||||
@@ -182,12 +182,18 @@
|
|||||||
"basicAuth": {
|
"basicAuth": {
|
||||||
"type": "http",
|
"type": "http",
|
||||||
"scheme": "basic"
|
"scheme": "basic"
|
||||||
|
},
|
||||||
|
"bearerAuth": {
|
||||||
|
"type": "http",
|
||||||
|
"scheme": "bearer",
|
||||||
|
"bearerFormat": "JWT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"security": [
|
"security": [
|
||||||
{
|
{
|
||||||
"basicAuth": []
|
"basicAuth": [],
|
||||||
|
"bearerAuth": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {},
|
||||||
"access_token": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "access_token"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"xml": {
|
"xml": {
|
||||||
"name": "AuthorizeRefreshRequest"
|
"name": "AuthorizeRefreshRequest"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user