From 48202e905f0087e991dc2719ce3efb496836e694 Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Fri, 24 Apr 2020 14:08:00 +0200 Subject: [PATCH] rename verify_api_key -> require_api_auth --- app/api/base.py | 2 +- app/api/views/alias.py | 22 +++++++++++----------- app/api/views/alias_options.py | 8 ++++---- app/api/views/apple.py | 4 ++-- app/api/views/new_custom_alias.py | 4 ++-- app/api/views/new_random_alias.py | 4 ++-- app/api/views/user_info.py | 4 ++-- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/api/base.py b/app/api/base.py index 2a87f661..5e7ca419 100644 --- a/app/api/base.py +++ b/app/api/base.py @@ -9,7 +9,7 @@ from app.models import ApiKey api_bp = Blueprint(name="api", import_name=__name__, url_prefix="/api") -def verify_api_key(f): +def require_api_auth(f): @wraps(f) def decorated(*args, **kwargs): if current_user.is_authenticated: diff --git a/app/api/views/alias.py b/app/api/views/alias.py index be2b79e5..62e6182b 100644 --- a/app/api/views/alias.py +++ b/app/api/views/alias.py @@ -3,7 +3,7 @@ from flask import jsonify from flask import request from flask_cors import cross_origin -from app.api.base import api_bp, verify_api_key +from app.api.base import api_bp, require_api_auth from app.api.serializer import ( AliasInfo, serialize_alias_info, @@ -25,7 +25,7 @@ from app.utils import random_string @api_bp.route("/aliases", methods=["GET", "POST"]) @cross_origin() -@verify_api_key +@require_api_auth def get_aliases(): """ Get aliases @@ -68,7 +68,7 @@ def get_aliases(): @api_bp.route("/v2/aliases", methods=["GET", "POST"]) @cross_origin() -@verify_api_key +@require_api_auth def get_aliases_v2(): """ Get aliases @@ -119,7 +119,7 @@ def get_aliases_v2(): @api_bp.route("/aliases/", methods=["DELETE"]) @cross_origin() -@verify_api_key +@require_api_auth def delete_alias(alias_id): """ Delete alias @@ -143,7 +143,7 @@ def delete_alias(alias_id): @api_bp.route("/aliases//toggle", methods=["POST"]) @cross_origin() -@verify_api_key +@require_api_auth def toggle_alias(alias_id): """ Enable/disable alias @@ -169,7 +169,7 @@ def toggle_alias(alias_id): @api_bp.route("/aliases//activities") @cross_origin() -@verify_api_key +@require_api_auth def get_alias_activities(alias_id): """ Get aliases @@ -225,7 +225,7 @@ def get_alias_activities(alias_id): @api_bp.route("/aliases/", methods=["PUT"]) @cross_origin() -@verify_api_key +@require_api_auth def update_alias(alias_id): """ Update alias note @@ -256,7 +256,7 @@ def update_alias(alias_id): @api_bp.route("/aliases/", methods=["GET"]) @cross_origin() -@verify_api_key +@require_api_auth def get_alias(alias_id): """ Get alias @@ -277,7 +277,7 @@ def get_alias(alias_id): @api_bp.route("/aliases//contacts") @cross_origin() -@verify_api_key +@require_api_auth def get_alias_contacts_route(alias_id): """ Get alias contacts @@ -311,7 +311,7 @@ def get_alias_contacts_route(alias_id): @api_bp.route("/aliases//contacts", methods=["POST"]) @cross_origin() -@verify_api_key +@require_api_auth def create_contact_route(alias_id): """ Create contact for an alias @@ -366,7 +366,7 @@ def create_contact_route(alias_id): @api_bp.route("/contacts/", methods=["DELETE"]) @cross_origin() -@verify_api_key +@require_api_auth def delete_contact(contact_id): """ Delete contact diff --git a/app/api/views/alias_options.py b/app/api/views/alias_options.py index f63186d9..92ed46c9 100644 --- a/app/api/views/alias_options.py +++ b/app/api/views/alias_options.py @@ -2,7 +2,7 @@ from flask import jsonify, request, g from flask_cors import cross_origin from sqlalchemy import desc -from app.api.base import api_bp, verify_api_key +from app.api.base import api_bp, require_api_auth from app.config import ALIAS_DOMAINS, DISABLE_ALIAS_SUFFIX from app.extensions import db from app.log import LOG @@ -12,7 +12,7 @@ from app.utils import convert_to_id, random_word @api_bp.route("/alias/options") @cross_origin() -@verify_api_key +@require_api_auth def options(): """ Return what options user has when creating new alias. @@ -88,7 +88,7 @@ def options(): @api_bp.route("/v2/alias/options") @cross_origin() -@verify_api_key +@require_api_auth def options_v2(): """ Return what options user has when creating new alias. @@ -167,7 +167,7 @@ def options_v2(): @api_bp.route("/v3/alias/options") @cross_origin() -@verify_api_key +@require_api_auth def options_v3(): """ Return what options user has when creating new alias. diff --git a/app/api/views/apple.py b/app/api/views/apple.py index 904c1542..c903ed21 100644 --- a/app/api/views/apple.py +++ b/app/api/views/apple.py @@ -7,7 +7,7 @@ from flask import jsonify from flask import request from flask_cors import cross_origin -from app.api.base import api_bp, verify_api_key +from app.api.base import api_bp, require_api_auth from app.config import APPLE_API_SECRET from app.extensions import db from app.log import LOG @@ -23,7 +23,7 @@ _PROD_URL = "https://buy.itunes.apple.com/verifyReceipt" @api_bp.route("/apple/process_payment", methods=["POST"]) @cross_origin() -@verify_api_key +@require_api_auth def apple_process_payment(): """ Process payment diff --git a/app/api/views/new_custom_alias.py b/app/api/views/new_custom_alias.py index 33fca4bf..be188d0b 100644 --- a/app/api/views/new_custom_alias.py +++ b/app/api/views/new_custom_alias.py @@ -2,7 +2,7 @@ from flask import g from flask import jsonify, request from flask_cors import cross_origin -from app.api.base import api_bp, verify_api_key +from app.api.base import api_bp, require_api_auth from app.api.serializer import serialize_alias_info, get_alias_info from app.config import MAX_NB_EMAIL_FREE_PLAN, ALIAS_DOMAINS from app.dashboard.views.custom_alias import verify_prefix_suffix @@ -14,7 +14,7 @@ from app.utils import convert_to_id @api_bp.route("/alias/custom/new", methods=["POST"]) @cross_origin() -@verify_api_key +@require_api_auth def new_custom_alias(): """ Create a new custom alias diff --git a/app/api/views/new_random_alias.py b/app/api/views/new_random_alias.py index 7ebae650..26def73e 100644 --- a/app/api/views/new_random_alias.py +++ b/app/api/views/new_random_alias.py @@ -2,7 +2,7 @@ from flask import g from flask import jsonify, request from flask_cors import cross_origin -from app.api.base import api_bp, verify_api_key +from app.api.base import api_bp, require_api_auth from app.api.serializer import serialize_alias_info, get_alias_info from app.config import MAX_NB_EMAIL_FREE_PLAN from app.extensions import db @@ -12,7 +12,7 @@ from app.models import Alias, AliasUsedOn, AliasGeneratorEnum @api_bp.route("/alias/random/new", methods=["POST"]) @cross_origin() -@verify_api_key +@require_api_auth def new_random_alias(): """ Create a new random alias diff --git a/app/api/views/user_info.py b/app/api/views/user_info.py index e53ab6f4..fd0426ee 100644 --- a/app/api/views/user_info.py +++ b/app/api/views/user_info.py @@ -1,12 +1,12 @@ from flask import jsonify, g from flask_cors import cross_origin -from app.api.base import api_bp, verify_api_key +from app.api.base import api_bp, require_api_auth @api_bp.route("/user_info") @cross_origin() -@verify_api_key +@require_api_auth def user_info(): """ Return user info given the api-key