progress on JWT

This commit is contained in:
lennyaiko
2025-04-03 16:54:14 +01:00
parent 4f2f3cccb4
commit 19870edf73
5 changed files with 103 additions and 15 deletions
+1
View File
@@ -7,6 +7,7 @@ BASIC_AUTH_PASSWORD=******
SWAGGER_URL="/documentation" SWAGGER_URL="/documentation"
API_URL="/swagger.json" API_URL="/swagger.json"
JWT_SECRET_KEY=******
DATABASE_USER=***** DATABASE_USER=*****
+1
View File
@@ -4,3 +4,4 @@ app.log
.DS_Store .DS_Store
migrations/__pycache__/ migrations/__pycache__/
migrations/*.pycg migrations/*.pycg
./vscode
+24
View File
@@ -0,0 +1,24 @@
{
"editor.lineNumbers": "off",
"editor.padding.top": 3,
"editor.padding.bottom": 3,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.fontSize": 14,
"editor.lineHeight": 4.5,
"editor.suggestFontSize": 15,
// "editor.suggestLineHeight": 4,
"breadcrumbs.enabled": false,
"workbench.tips.enabled": false,
"workbench.statusBar.visible": false,
// "workbench.editor.showTabs": "single",
"git.enableSmartCommit": true,
"workbench.editor.editorActionsLocation": "hidden",
// "workbench.activityBar.location": "hidden",
"workbench.editor.enablePreviewFromQuickOpen": false,
"editor.lightbulb.enabled": "off",
"editor.selectionHighlight": false,
"editor.overviewRulerBorder": false,
"editor.renderLineHighlight": "none",
"editor.occurrencesHighlight": "off"
}
+21 -13
View File
@@ -6,7 +6,7 @@ from app.api.services import (
LoanStatusService, LoanStatusService,
RepaymentService, RepaymentService,
CustomerConsentService, CustomerConsentService,
NotificationCallbackService NotificationCallbackService,
) )
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
@@ -23,21 +23,20 @@ def cors_middleware():
# Swagger JSON file # Swagger JSON file
@api.route("/swagger.json", methods=['GET']) @api.route("/swagger.json", methods=["GET"])
def swagger_json(): def swagger_json():
swagger_dir = os.path.join("swagger") swagger_dir = os.path.join("swagger")
return send_from_directory(swagger_dir, "digifi_swagger.json") return send_from_directory(swagger_dir, "digifi_swagger.json")
@api.route("/swagger/<path:filename>")
@api.route('/swagger/<path:filename>')
def serve_paths(filename): def serve_paths(filename):
swagger_dir = os.path.join("swagger") swagger_dir = os.path.join("swagger")
return send_from_directory(swagger_dir, filename) return send_from_directory(swagger_dir, filename)
# EligibilityCheck Endpoint # EligibilityCheck Endpoint
@api.route('/EligibilityCheck', methods=['POST']) @api.route("/EligibilityCheck", methods=["POST"])
@require_auth @require_auth
def eligibility_check(): def eligibility_check():
data = request.get_json() data = request.get_json()
@@ -45,8 +44,9 @@ def eligibility_check():
response = EligibilityCheckService.process_request(data) response = EligibilityCheckService.process_request(data)
return response return response
# SelectOffer Endpoint # SelectOffer Endpoint
@api.route('/SelectOffer', methods=['POST']) @api.route("/SelectOffer", methods=["POST"])
@require_auth @require_auth
def select_offer(): def select_offer():
data = request.get_json() data = request.get_json()
@@ -56,7 +56,7 @@ def select_offer():
# ProvideLoan Endpoint # ProvideLoan Endpoint
@api.route('/ProvideLoan', methods=['POST']) @api.route("/ProvideLoan", methods=["POST"])
@require_auth @require_auth
def provide_loan(): def provide_loan():
data = request.get_json() data = request.get_json()
@@ -66,7 +66,7 @@ def provide_loan():
# LoanStatus Endpoint # LoanStatus Endpoint
@api.route('/LoanStatus', methods=['POST']) @api.route("/LoanStatus", methods=["POST"])
@require_auth @require_auth
def loan_status(): def loan_status():
data = request.get_json() data = request.get_json()
@@ -76,7 +76,7 @@ def loan_status():
# Repayment Endpoint # Repayment Endpoint
@api.route('/Repayment', methods=['POST']) @api.route("/Repayment", methods=["POST"])
@require_auth @require_auth
def repayment(): def repayment():
data = request.get_json() data = request.get_json()
@@ -86,7 +86,7 @@ def repayment():
# CustomerConsent Endpoint # CustomerConsent Endpoint
@api.route('/CustomerConsent', methods=['POST']) @api.route("/CustomerConsent", methods=["POST"])
@require_auth @require_auth
def customer_consent(): def customer_consent():
data = request.get_json() data = request.get_json()
@@ -96,7 +96,7 @@ def customer_consent():
# NotificationCallback Endpoint # NotificationCallback Endpoint
@api.route('/NotificationCallback', methods=['POST']) @api.route("/NotificationCallback", methods=["POST"])
@require_auth @require_auth
def notification_callback(): def notification_callback():
data = request.get_json() data = request.get_json()
@@ -106,6 +106,14 @@ def notification_callback():
# Health Check Endpoint # Health Check Endpoint
@api.route('/health', methods=['GET']) @api.route("/health", methods=["GET"])
def health_check(): def health_check():
return {"status": "ok"} , 200 return {"status": "ok"}, 200
# Authorize endpoint
@api.route("/Authorize", methods=["POST"])
def authorize():
data = request.get_json()
# logger.info(f"Authorize request received: {data}")
return jsonify(data)
+54
View File
@@ -0,0 +1,54 @@
{
"post": {
"tags": ["Authorize"],
"summary": "Customer Authorize Request",
"description": "Customer Authorize Request",
"operationId": "Authorize",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/AuthorizeRequest.json"
}
},
"application/xml": {
"schema": {
"$ref": "../schemas/AuthorizeRequest.json"
}
},
"application/x-www-form-urlencoded": {
"schema": {
"$ref": "../schemas/AuthorizeRequest.json"
}
}
}
},
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/AuthorizeResponse.json"
}
},
"application/xml": {
"schema": {
"$ref": "../schemas/AuthorizeResponse.json"
}
}
}
},
"400": {
"description": "Invalid request parameters"
},
"422": {
"description": "Validation exception"
},
"500": {
"description": "Internal server error"
}
}
}
}