Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from flask import Flask, jsonify, request
from flask_jwt_extended import jwt_required, JWTManager, get_jwt_identity, get_jwt
import ssl
from werkzeug import serving
import socket, ssl
import OpenSSL
from OpenSSL import crypto
import jwt
import pyone
app = Flask(__name__)
jwt_flask = JWTManager(app)
with open("Responses/cert_server.pem", "rb") as cert_file:
cert= cert_file.read()
crtObj = crypto.load_certificate(crypto.FILETYPE_PEM, cert)
pubKeyObject = crtObj.get_pubkey()
pubKeyString = crypto.dump_publickey(crypto.FILETYPE_PEM,pubKeyObject)
app.config['JWT_ALGORITHM'] = 'RS256'
app.config['JWT_PUBLIC_KEY'] = pubKeyString
@app.route("/hello", methods=["POST"])
@jwt_required()
def hello():
request_data = request.get_json()
user_name = request_data['name']
return jsonify(f"Hello: {user_name}, welcome to CAPIF.")
if __name__ == '__main__':
serving.run_simple("0.0.0.0", 8088, app)