提问人:IloveJSC 提问时间:10/26/2023 最后编辑:IloveJSC 更新时间:10/26/2023 访问量:50
当我为 OAuth 2.0 身份验证配置 pgAdmin 时,该按钮不会出现在 Web 端
When I configure pgAdmin for OAuth 2.0 authentication, the button does not appear on the web side
问:
这是我的配置config_local.py,为了便于查看,我删除了换行符和注释:
# -*- coding: utf-8 -*-
import builtins
import logging
import os
import sys
logging.basicConfig(level=logging.INFO)
logging.info('===== This config file has been loaded. =====')
root = os.path.dirname(os.path.realpath(__file__))
if sys.path[0] != root:
sys.path.insert(0, root)
CONFIG_DATABASE_CONNECTION_POOL_SIZE = 5
CONFIG_DATABASE_CONNECTION_MAX_OVERFLOW = 100
from pgadmin.utils import env, IS_WIN, fs_short_path
APP_NAME = 'pgAdmin 4'
APP_ICON = 'pg-icon'
APP_RELEASE = 7
APP_REVISION = 8
APP_SUFFIX = ''
APP_VERSION_INT = 70800
if not APP_SUFFIX:
APP_VERSION = '%s.%s' % (APP_RELEASE, APP_REVISION)
else:
APP_VERSION = '%s.%s-%s' % (APP_RELEASE, APP_REVISION, APP_SUFFIX)
APP_COPYRIGHT = 'Copyright (C) 2013 - 2023, The pgAdmin Development Team'
HELP_PATH = '../../../docs/en_US/_build/html/'
LANGUAGES = {
'en': 'English',
'zh': 'Chinese (Simplified)',
'cs': 'Czech',
'fr': 'French',
'de': 'German',
'id': 'Indonesian',
'it': 'Italian',
'ja': 'Japanese',
'ko': 'Korean',
'pl': 'Polish',
'pt_BR': 'Portuguese (Brazilian)',
'ru': 'Russian',
'es': 'Spanish',
}
MODULE_BLACKLIST = ['test']
NODE_BLACKLIST = []
if (not hasattr(builtins, 'SERVER_MODE')) or builtins.SERVER_MODE is None:
SERVER_MODE = True
else:
SERVER_MODE = builtins.SERVER_MODE
WTF_CSRF_HEADERS = ['X-pgA-CSRFToken']
DESKTOP_USER = '[email protected]'
DEFAULT_SERVER = '127.0.0.1'
DEFAULT_SERVER_PORT = 5050
WEB_SERVER = 'Python'
X_FRAME_OPTIONS = "SAMEORIGIN"
CONTENT_SECURITY_POLICY = "default-src ws: http: data: blob: 'unsafe-inline'" \
" 'unsafe-eval';"
STRICT_TRANSPORT_SECURITY_ENABLED = False
STRICT_TRANSPORT_SECURITY = "max-age=31536000; includeSubDomains"
X_CONTENT_TYPE_OPTIONS = "nosniff"
X_XSS_PROTECTION = "1; mode=block"
ALLOWED_HOSTS = []
SECURITY_PASSWORD_HASH = 'pbkdf2_sha512'
PASSWORD_LENGTH_MIN = 6
PROXY_X_FOR_COUNT = 1
PROXY_X_PROTO_COUNT = 1
PROXY_X_HOST_COUNT = 0
PROXY_X_PORT_COUNT = 1
PROXY_X_PREFIX_COUNT = 0
COMPRESS_MIMETYPES = [
'text/html', 'text/css', 'text/xml', 'application/json',
'application/javascript'
]
COMPRESS_LEVEL = 9
COMPRESS_MIN_SIZE = 500
SEND_FILE_MAX_AGE_DEFAULT = 31556952
APP_VERSION_PARAM = 'ver'
APP_VERSION_EXTN = ('.css', '.js', '.html', '.svg', '.png', '.gif', '.ico')
if IS_WIN:
DATA_DIR = os.path.realpath(
os.path.join(fs_short_path(env('APPDATA')), "pgAdmin")
)
else:
if SERVER_MODE:
DATA_DIR = '/var/lib/pgadmin'
else:
DATA_DIR = os.path.realpath(os.path.expanduser('~/.pgadmin/'))
LOGIN_BANNER = ""
DEBUG = False
CONSOLE_LOG_LEVEL = logging.WARNING
FILE_LOG_LEVEL = logging.WARNING
CONSOLE_LOG_FORMAT = '%(asctime)s: %(levelname)s\t%(name)s:\t%(message)s'
FILE_LOG_FORMAT = '%(asctime)s: %(levelname)s\t%(name)s:\t%(message)s'
if SERVER_MODE and not IS_WIN:
LOG_FILE = '/var/log/pgadmin/pgadmin4.log'
else:
LOG_FILE = os.path.join(DATA_DIR, 'pgadmin4.log')
LOG_ROTATION_SIZE = 10 # In MBs
LOG_ROTATION_AGE = 1440 # In minutes
LOG_ROTATION_MAX_LOG_FILES = 90 # Maximum number of backups to retain
PG_DEFAULT_DRIVER = 'psycopg3'
MAX_SESSION_IDLE_TIME = 60
CONFIG_DATABASE_URI = ''
SQLITE_PATH = env('SQLITE_PATH') or os.path.join(DATA_DIR, 'pgadmin4.db')
SQLITE_TIMEOUT = 500
ALLOW_SAVE_PASSWORD = True
MAX_QUERY_HIST_STORED = 20
SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions')
SESSION_COOKIE_NAME = 'pga4_session'
MAIL_SERVER = 'localhost'
MAIL_PORT = 25
MAIL_USE_SSL = False
MAIL_USE_TLS = False
MAIL_USERNAME = ''
MAIL_PASSWORD = ''
MAIL_DEBUG = False
SECURITY_EMAIL_SENDER = 'no-reply@localhost'
SECURITY_EMAIL_SUBJECT_PASSWORD_RESET = "Password reset instructions for %s" \
% APP_NAME
SECURITY_EMAIL_SUBJECT_PASSWORD_NOTICE = "Your %s password has been reset" \
% APP_NAME
SECURITY_EMAIL_SUBJECT_PASSWORD_CHANGE_NOTICE = \
"Your password for %s has been changed" % APP_NAME
CHECK_EMAIL_DELIVERABILITY = False
SECURITY_EMAIL_VALIDATOR_ARGS = \
{"check_deliverability": CHECK_EMAIL_DELIVERABILITY}
UPGRADE_CHECK_ENABLED = True
UPGRADE_CHECK_URL = 'https://www.pgadmin.org/versions.json'
UPGRADE_CHECK_KEY = 'pgadmin4'
CA_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)),
"cacert.pem")
CHECK_SUPPORTED_BROWSER = True
STORAGE_DIR = os.path.join(DATA_DIR, 'storage')
DEFAULT_BINARY_PATHS = {
"pg": "",
"pg-12": "",
"pg-13": "",
"pg-14": "",
"pg-15": "",
"pg-16": "",
"ppas": "",
"ppas-12": "",
"ppas-13": "",
"ppas-14": "",
"ppas-15": "",
"ppas-16": ""
}
TEST_SQLITE_PATH = os.path.join(DATA_DIR, 'test_pgadmin4.db')
THREADED_MODE = True
SQLALCHEMY_TRACK_MODIFICATIONS = False
ON_DEMAND_RECORD_COUNT = 1000
SHOW_GRAVATAR_IMAGE = True
COOKIE_DEFAULT_PATH = '/'
COOKIE_DEFAULT_DOMAIN = None
SESSION_COOKIE_DOMAIN = None
SESSION_COOKIE_SAMESITE = 'Lax'
SESSION_COOKIE_SECURE = False
SESSION_COOKIE_HTTPONLY = True
SESSION_SKIP_PATHS = [
'/misc/ping'
]
SESSION_EXPIRATION_TIME = 1
if not SERVER_MODE:
SESSION_EXPIRATION_TIME = 7
CHECK_SESSION_FILES_INTERVAL = 24
USER_INACTIVITY_TIMEOUT = 0
OVERRIDE_USER_INACTIVITY_TIMEOUT = True
SUPPORT_SSH_TUNNEL = True
ALLOW_SAVE_TUNNEL_PASSWORD = False
MASTER_PASSWORD_REQUIRED = True
MASTER_PASSWORD_HOOK = None
ENHANCED_COOKIE_PROTECTION = True
AUTHENTICATION_SOURCES = ['oauth2', 'internal']
MAX_LOGIN_ATTEMPTS = 3
LOGIN_ATTEMPT_FIELDS = ['password']
LDAP_AUTO_CREATE_USER = True
LDAP_CONNECTION_TIMEOUT = 10
LDAP_SERVER_URI = 'ldap://<ip-address>:<port>'
LDAP_USERNAME_ATTRIBUTE = '<User-id>'
LDAP_BIND_USER = None
LDAP_BIND_PASSWORD = None
LDAP_ANONYMOUS_BIND = False
LDAP_BASE_DN = '<Base-DN>'
LDAP_BIND_FORMAT = '{LDAP_USERNAME_ATTRIBUTE}={LDAP_USERNAME},{LDAP_BASE_DN}'
LDAP_SEARCH_BASE_DN = '<Search-Base-DN>'
LDAP_DN_CASE_SENSITIVE = False
LDAP_SEARCH_FILTER = '(objectclass=*)'
LDAP_SEARCH_SCOPE = 'SUBTREE'
LDAP_USE_STARTTLS = False
LDAP_CA_CERT_FILE = ''
LDAP_CERT_FILE = ''
LDAP_KEY_FILE = ''
KRB_APP_HOST_NAME = DEFAULT_SERVER
KRB_KTNAME = '<KRB5_KEYTAB_FILE>'
KRB_AUTO_CREATE_USER = True
KERBEROS_CCACHE_DIR = os.path.join(DATA_DIR, 'krbccache')
AZURE_CREDENTIAL_CACHE_DIR = os.path.join(DATA_DIR, 'azurecredentialcache')
OAUTH2_CONFIG = [
{
'OAUTH2_NAME': 'Google',
'OAUTH2_DISPLAY_NAME': 'Google',
'OAUTH2_CLIENT_ID': 'clientid',
'OAUTH2_CLIENT_SECRET': 'secret',
'OAUTH2_TOKEN_URL': 'https://oauth2.googleapis.com/token',
'OAUTH2_AUTHORIZATION_URL': 'https://accounts.google.com/o/oauth2/auth',
'OAUTH2_SERVER_METADATA_URL': None,
'OAUTH2_API_BASE_URL': None,
'OAUTH2_USERINFO_ENDPOINT': 'userinfo',
'OAUTH2_SCOPE': 'openid email profile',
'OAUTH2_USERNAME_CLAIM': None,
'OAUTH2_ICON': 'fa-google',
'OAUTH2_BUTTON_COLOR': '#0000ff',
'OAUTH2_ADDITIONAL_CLAIMS': None,
}
]
OAUTH2_AUTO_CREATE_USER = True
WEBSERVER_AUTO_CREATE_USER = True
WEBSERVER_REMOTE_USER = 'REMOTE_USER'
MFA_ENABLED = True
MFA_FORCE_REGISTRATION = False
MFA_SUPPORTED_METHODS = ["email", "authenticator"]
MFA_EMAIL_SUBJECT = None
ENABLE_PSQL = False
ENABLE_BINARY_PATH_BROWSING = False
SHARED_STORAGE = []
AUTO_DISCOVER_SERVERS = True
SERVER_HEARTBEAT_TIMEOUT = 30 # In seconds
from pgadmin.evaluate_config import evaluate_and_patch_config
locals().update(evaluate_and_patch_config(locals()))
我的docker compose文件:
version: '3'
services:
postgres:
image: postgres
environment:
POSTGRES_USER: my_username
POSTGRES_PASSWORD: my_password
POSTGRES_DB: my_database
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
pgadmin:
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: my_password
ports:
- "5050:80"
depends_on:
- postgres
volumes:
- /my/config/dir/config_local.py:/pgadmin4/config_local.py
volumes:
postgres_data:
我整个下午都在调试,我正在使用最新版本的 pgadmin:7.8,并且我已经逐个版本进行了回测,并且我最高了 5.X 版本,但我仍然无法让此 SSO 登录按钮出现在页面上。
我已经疯了,为什么无论我如何调试,我都不能让这个该死的按钮出现在页面上?
答: 暂无答案
评论