rename verify_api_key -> require_api_auth

This commit is contained in:
Son NK 2020-04-24 14:08:00 +02:00 committed by Son NK
parent 78e94da08c
commit 48202e905f
7 changed files with 24 additions and 24 deletions

View file

@ -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:

View file

@ -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/<int:alias_id>", 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/<int:alias_id>/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/<int:alias_id>/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/<int:alias_id>", 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/<int:alias_id>", 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/<int:alias_id>/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/<int:alias_id>/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/<int:contact_id>", methods=["DELETE"])
@cross_origin()
@verify_api_key
@require_api_auth
def delete_contact(contact_id):
"""
Delete contact

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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