Created
August 23, 2022 10:14
-
-
Save KalanaDananjaya/45bf9a8db860473752c480556a0c508d to your computer and use it in GitHub Desktop.
CIBA - Automated Approval Endpoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask,jsonify,make_response, request | |
import json | |
from flask import Response | |
import mysql.connector | |
import os | |
ASSETS_DIR = os.path.dirname(os.path.abspath(__file__)) | |
app = Flask('app') | |
mydb = mysql.connector.connect( | |
host="localhost", | |
user="root", | |
password="root", | |
database="openbank_apimgtdb_conformance" | |
) | |
mycursor = mydb.cursor() | |
@app.route('/automatedapproval', methods=["GET","POST"]) | |
def automatedapproval(): | |
body = {} | |
args = request.args | |
action = args.get("action") | |
if (action == "allow"): | |
action = "AUTHENTICATED" | |
if (action=="deny"): | |
action = "CONSENT_DENIED" | |
auth_req_id = args.get("token") | |
query = "UPDATE IDN_OAUTH2_CIBA_AUTH_CODE SET AUTH_REQ_STATUS = '{action}', AUTHENTICATED_USER_NAME='[email protected]', USER_STORE_DOMAIN='abc', TENANT_ID = 1, IDP_ID = 1 WHERE AUTH_REQ_ID = '{token}'".format(action = action, token = auth_req_id) | |
print(query) | |
mycursor.execute(query) | |
mydb.commit() | |
response = make_response(jsonify(body)) | |
response.headers['content-type'] = 'application/json' | |
return response | |
context = ('cert.pem', 'key.pem') | |
app.run(host = '0.0.0.0', port = 9000, ssl_context=context) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment