Unverified Commit 7fd64b72 authored by Yeuoly's avatar Yeuoly

rename: enterprise to inner api

parent 62b79cd9
......@@ -2,8 +2,8 @@
EDITION=SELF_HOSTED
# Enterprise Options
ENTERPRISE=
ENTERPRISE_KEY=
INNER_API=
INNER_API_KEY=
# Your App secret key will be used for securely signing the session cookie
# Make sure you are changing this key for your deployment with a strong key.
......
......@@ -112,7 +112,7 @@ def initialize_extensions(app):
@login_manager.request_loader
def load_user_from_request(request_from_flask_login):
"""Load user based on the request."""
if request.blueprint in ['console', 'enterprise']:
if request.blueprint in ['console', 'inner_api']:
# Check if the user_id contains a dot, indicating the old format
auth_header = request.headers.get('Authorization', '')
if not auth_header:
......@@ -150,7 +150,7 @@ def register_blueprints(app):
from controllers.files import bp as files_bp
from controllers.service_api import bp as service_api_bp
from controllers.web import bp as web_bp
from controllers.enterprise import bp as enterprise_bp
from controllers.inner_api import bp as inner_api_bp
CORS(service_api_bp,
allow_headers=['Content-Type', 'Authorization', 'X-App-Code'],
......@@ -186,7 +186,7 @@ def register_blueprints(app):
)
app.register_blueprint(files_bp)
app.register_blueprint(enterprise_bp)
app.register_blueprint(inner_api_bp)
# create app
app = create_app()
......
......@@ -121,9 +121,9 @@ class Config:
self.SECRET_KEY = get_env('SECRET_KEY')
# Enterprise Edition
# Only the enterprise edition can be set to True
self.ENTERPRISE = get_bool_env('ENTERPRISE')
self.ENTERPRISE_KEY = get_env('ENTERPRISE_KEY')
# Only the inner_api edition can be set to True
self.INNER_API = get_bool_env('INNER_API')
self.INNER_API_KEY = get_env('INNER_API_KEY')
# cors settings
self.CONSOLE_CORS_ALLOW_ORIGINS = get_cors_allow_origins(
......
from flask import Blueprint
from libs.external_api import ExternalApi
bp = Blueprint('enterprise', __name__, url_prefix='/enterprise/api')
bp = Blueprint('inner_api', __name__, url_prefix='/inner/api')
api = ExternalApi(bp)
from . import authorization
\ No newline at end of file
from flask_login import current_user
from flask_restful import Resource
from controllers.enterprise import api
from controllers.console.setup import setup_required
from controllers.inner_api import api
from controllers.inner_api.wraps import inner_api_only
from libs.login import login_required
from controllers.enterprise.wraps import enterprise_only
from flask_restful import Resource
class EnterpriseAuthorizationApi(Resource):
"""Authorization API for enterprise edition, share user and tenant info."""
"""Authorization API for inner_api edition, share user and tenant info."""
@setup_required
@login_required
@enterprise_only
@inner_api_only
def get(self):
current_tenant = current_user.current_tenant
return {
......
......@@ -2,15 +2,16 @@ from functools import wraps
from flask import abort, current_app, request
def enterprise_only(view):
def inner_api_only(view):
@wraps(view)
def decorated(*args, **kwargs):
if not current_app.config['ENTERPRISE']:
if not current_app.config['INNER_API']:
abort(404)
# get header 'X-Enterprise-Key'
enterprise_key = request.headers.get('X-Enterprise-Key')
if not enterprise_key or enterprise_key != current_app.config['ENTERPRISE_KEY']:
# get header 'X-Inner-Api-Key'
inner_api_key = request.headers.get('X-Inner-Api-Key')
if not inner_api_key or inner_api_key != current_app.config['INNER_API_KEY']:
abort(404)
return view(*args, **kwargs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment