-
-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated OAS to include auth and added swagger ui * custom 401 handler for connexion to match rest * update readme
- Loading branch information
Showing
8 changed files
with
84 additions
and
62 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
import os | ||
import connexion | ||
from flask import jsonify | ||
from flask_sqlalchemy import SQLAlchemy | ||
|
||
vuln_app = connexion.App(__name__, specification_dir='./openapi_specs') | ||
|
||
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(vuln_app.root_path, 'database/database.db') | ||
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(vuln_app.app.root_path, 'database/database.db') | ||
vuln_app.app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI | ||
vuln_app.app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False | ||
|
||
vuln_app.app.config['SECRET_KEY'] = 'random' | ||
# start the db | ||
db = SQLAlchemy(vuln_app.app) | ||
|
||
vuln_app.add_api('openapi3.yml') | ||
|
||
@vuln_app.app.errorhandler(401) | ||
def custom_401(error): | ||
# Custom 401 to match the original response sent by Vampi | ||
response = jsonify({"status": "fail", "message": "Invalid token. Please log in again."}) | ||
response.status_code = 401 | ||
return response | ||
|
||
|
||
vuln_app.add_api('openapi3.yml') |
This file contains 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
Oops, something went wrong.