|
|
@@ -27,9 +27,8 @@ from werkzeug.exceptions import HTTPException |
|
|
|
from sqlalchemy.ext.declarative import declarative_base |
|
|
|
|
|
|
|
from realms.modules.search.models import Search |
|
|
|
from realms.lib.util import to_canonical, remove_ext, mkdir_safe, gravatar_url, to_dict |
|
|
|
from realms.lib.util import to_canonical, remove_ext, mkdir_safe, gravatar_url, to_dict, is_su, in_virtualenv |
|
|
|
from realms.lib.hook import HookModelMeta, HookMixin |
|
|
|
from realms.lib.util import is_su, in_virtualenv |
|
|
|
from realms.version import __version__ |
|
|
|
|
|
|
|
|
|
|
@@ -216,22 +215,6 @@ def create_app(config=None): |
|
|
|
if app.config.get('DB_URI'): |
|
|
|
db.metadata.create_all(db.get_engine(app)) |
|
|
|
|
|
|
|
if app.config["AUTH_PROXY"]: |
|
|
|
logger = logging.getLogger("realms.auth") |
|
|
|
|
|
|
|
@app.before_request |
|
|
|
def proxy_auth(): |
|
|
|
from realms.modules.auth.proxy.models import User as ProxyUser |
|
|
|
remote_user = request.headers.get(app.config["AUTH_PROXY_HEADER_NAME"]) |
|
|
|
if remote_user: |
|
|
|
if current_user.is_authenticated: |
|
|
|
if current_user.id == remote_user: |
|
|
|
return |
|
|
|
logger.info("login in realms and login by proxy are different: '{}'/'{}'".format( |
|
|
|
current_user.id, remote_user)) |
|
|
|
logout_user() |
|
|
|
logger.info("User logged in by proxy as '{}'".format(remote_user)) |
|
|
|
ProxyUser.do_login(remote_user) |
|
|
|
|
|
|
|
return app |
|
|
|
|
|
|
|