only check api keys on selected resources
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
from flask import Flask, jsonify, Response, request
|
||||
from api.extensions import db, esales
|
||||
from api.helpers import check_api_key
|
||||
from api.validators import ValidationError
|
||||
|
||||
|
||||
@@ -32,7 +31,4 @@ def create_app(config_name='config'):
|
||||
app.register_blueprint(categories.mod)
|
||||
app.register_blueprint(prices.mod)
|
||||
|
||||
# authentication
|
||||
app.before_request(check_api_key)
|
||||
|
||||
return app
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
from flask import Blueprint, request, jsonify
|
||||
from api import db, tasks
|
||||
from api.models import Category
|
||||
from api.helpers import pagination_to_dict
|
||||
from api.helpers import pagination_to_dict, check_api_key
|
||||
|
||||
mod = Blueprint('categories', __name__, url_prefix='/categories')
|
||||
|
||||
mod.before_request(check_api_key)
|
||||
|
||||
|
||||
@mod.route("/", methods=["GET"])
|
||||
def list():
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
from flask import Blueprint, request, jsonify
|
||||
from api import db, tasks
|
||||
from api.models import Designer
|
||||
from api.helpers import pagination_to_dict
|
||||
from api.helpers import pagination_to_dict, check_api_key
|
||||
from api.validators import validate_jsonschema
|
||||
|
||||
|
||||
mod = Blueprint('designers', __name__, url_prefix='/designers')
|
||||
|
||||
mod.before_request(check_api_key)
|
||||
|
||||
create_designer_schema = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from flask import Blueprint, request, jsonify, abort
|
||||
from api.helpers import check_api_key
|
||||
from api.validators import validate_territory, validate_number, validate_exists
|
||||
from api.models.product import Material
|
||||
from api.models.contract_customer import ContractCustomer
|
||||
@@ -9,6 +10,8 @@ from api.lib.limits import calculate_canvas_limits
|
||||
|
||||
mod = Blueprint('prices', __name__, url_prefix='/prices')
|
||||
|
||||
mod.before_request(check_api_key)
|
||||
|
||||
|
||||
def get_reseller():
|
||||
dealerurl = request.args.get('dealerurl')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from flask import Blueprint, jsonify
|
||||
from flask import Blueprint, jsonify, url_for
|
||||
|
||||
mod = Blueprint('server', __name__)
|
||||
|
||||
|
||||
@@ -6,3 +6,4 @@ ESALES_URL = ''
|
||||
TESTING = True
|
||||
DEBUG = True
|
||||
SQLALCHEMY_ECHO = False
|
||||
API_KEYS = None # api keys are disabled in test
|
||||
+9
-1
@@ -5,6 +5,7 @@ import json
|
||||
import base64
|
||||
from api import create_app
|
||||
from flask import Flask
|
||||
from api.helpers import check_api_key
|
||||
from api.validators import ValidationError, validate_exists, validate_number, validate_territory, validate_jsonschema
|
||||
|
||||
|
||||
@@ -13,7 +14,14 @@ class TestHttpBasicAuth(flask_testing.TestCase):
|
||||
api_key = 'secret'
|
||||
|
||||
def create_app(self):
|
||||
return create_app('tests.config')
|
||||
app = Flask(__name__)
|
||||
app.before_request(check_api_key)
|
||||
|
||||
@app.route('/', methods=['GET'])
|
||||
def index():
|
||||
return 'ok'
|
||||
|
||||
return app
|
||||
|
||||
def _enable_basic_auth(self):
|
||||
self.app.config['API_KEYS'] = [self.api_key]
|
||||
|
||||
Reference in New Issue
Block a user