mirror of
https://github.com/langgenius/dify.git
synced 2026-05-27 04:16:16 +08:00
Co-authored-by: GareArc <garethcxy@dify.ai> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: L1nSn0w <l1nsn0w@qq.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: gigglewang <gigglewang@dify.ai> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
24 lines
659 B
Python
24 lines
659 B
Python
"""Bind the bearer authenticator at startup. Must run after ext_database
|
|
and ext_redis (needs both factories).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from configs import dify_config
|
|
from dify_app import DifyApp
|
|
from extensions.ext_database import db
|
|
from extensions.ext_redis import redis_client
|
|
from libs.oauth_bearer import build_and_bind
|
|
|
|
|
|
def is_enabled() -> bool:
|
|
return dify_config.ENABLE_OAUTH_BEARER
|
|
|
|
|
|
def init_app(app: DifyApp) -> None:
|
|
# scoped_session isn't a context manager; request teardown closes it.
|
|
def session_factory():
|
|
return db.session
|
|
|
|
build_and_bind(session_factory=session_factory, redis_client=redis_client)
|