|
1 | 1 | import logging |
2 | 2 | import os |
3 | | - |
4 | | -# The realm, where users are allowed to login as administrators |
5 | | -SUPERUSER_REALM = os.getenv("SUPERUSER_REALM","admin,helpdesk").split(',') |
6 | | - |
7 | | -# Your database |
8 | | -SQLALCHEMY_DATABASE_URI = os.getenv("DB_API") + "://" + os.getenv("DB_USER") + ":" + os.getenv("DB_PASSWORD") + "@" + os.getenv("DB_HOST") + ":" + os.getenv("DB_PORT") + "/" + os.getenv("DB_NAME") + os.getenv("DB_EXTRA_PARAMS") if (os.getenv("DB_PASSWORD")) else "sqlite:////privacyidea/etc/persistent/data.sqlite" |
9 | | - |
10 | | -# This is used to encrypt the auth_token |
11 | | -SECRET_KEY = open('%s' % os.getenv("PI_SECRET")).read().rstrip('\n') if os.path.exists(os.getenv("PI_SECRET")) else os.getenv("PI_SECRET") |
12 | | - |
13 | | -# This is used to encrypt the admin passwords |
14 | | -PI_PEPPER = open('%s' % os.getenv("PI_PEPPER")).read().rstrip('\n') if os.path.exists(os.getenv("PI_PEPPER")) else os.getenv("PI_PEPPER") |
15 | | -# This is used to encrypt the token data and token passwords |
16 | | -PI_ENCFILE = '/privacyidea/etc/persistent/enckey' |
17 | | - |
18 | | -# Scripts |
19 | | -PI_SCRIPT_HANDLER_DIRECTORY='/privacyidea/scripts' |
20 | | - |
21 | | -# This is used to sign the audit log |
22 | | -PI_AUDIT_KEY_PRIVATE = '/privacyidea/etc/persistent/private.pem' |
23 | | -PI_AUDIT_KEY_PUBLIC = '/privacyidea/etc/persistent/public.pem' |
24 | | -PI_AUDIT_SQL_TRUNCATE = True |
25 | | - |
26 | | -# The Class for managing the SQL connection pool |
27 | | -PI_ENGINE_REGISTRY_CLASS = os.getenv("PI_REGISTRY_CLASS", "shared") |
28 | | -PI_AUDIT_POOL_SIZE = 20 |
29 | | - |
30 | | -# Logging |
31 | | -PI_LOGCONFIG = '/privacyidea/etc/logging.cfg' |
32 | | -PI_LOGLEVEL = logging.getLevelName(os.getenv("PI_LOGLEVEL", "INFO").upper()) |
33 | | -PI_UUID_FILE = '/privacyidea/etc/persistent/uuid.txt' |
34 | | -# Use true if DB cLuster used (e.g. galera, oracle...) |
35 | | -SQLALCHEMY_ENGINE_OPTIONS= {"pool_pre_ping": os.getenv("PI_SQLALCHEMY_ENGINE_OPTIONS", "False")} |
| 3 | +import pprint |
| 4 | + |
| 5 | +pi_os_special_vars = { |
| 6 | + 'SUPERUSER_REALM': os.getenv("SUPERUSER_REALM","admin,helpdesk").split(','), |
| 7 | + 'PI_ENCFILE' : '/privacyidea/etc/persistent/enckey', |
| 8 | + 'PI_SCRIPT_HANDLER_DIRECTORY' : '/privacyidea/scripts', |
| 9 | + 'PI_AUDIT_KEY_PRIVATE' : '/privacyidea/etc/persistent/private.pem', |
| 10 | + 'PI_AUDIT_KEY_PUBLIC' : '/privacyidea/etc/persistent/public.pem', |
| 11 | + 'PI_AUDIT_SQL_TRUNCATE' : os.getenv("PI_AUDIT_SQL_TRUNCATE",True), |
| 12 | + 'PI_ENGINE_REGISTRY_CLASS': os.getenv("PI_REGISTRY_CLASS", "shared"), |
| 13 | + 'PI_AUDIT_POOL_SIZE' : os.getenv("PI_AUDIT_POOL_SIZE", "20"), |
| 14 | + 'PI_AUDIT_NO_SIGN' : os.getenv("PI_AUDIT_POOL_SIZE", False), |
| 15 | + 'PI_LOGCONFIG' : '/privacyidea/etc/logging.cfg', |
| 16 | + 'PI_LOGLEVEL' : logging.getLevelName(os.getenv("PI_LOGLEVEL", "INFO").upper()), |
| 17 | + 'PI_UUID_FILE' : '/privacyidea/etc/persistent/uuid.txt', |
| 18 | + 'PI_SQLALCHEMY_ENGINE_OPTIONS' : {"pool_pre_ping": os.getenv("PI_SQLALCHEMY_ENGINE_OPTIONS", "False")} , |
| 19 | + 'SQLALCHEMY_DATABASE_URI' : os.getenv("DB_API",'sqlite:////privacyidea/etc/persistent/data.sqlite') + "://" + os.getenv("DB_USER",'') + ":" + os.getenv("DB_PASSWORD",'') + "@" + os.getenv("DB_HOST",'') + ":" + os.getenv("DB_PORT",'') + "/" + os.getenv("DB_NAME",'') + os.getenv("DB_EXTRA_PARAMS",'') |
| 20 | + } |
| 21 | + |
| 22 | +pi_os_vars = {key: value for key, value in os.environ.items() if key.startswith('PI_')} |
| 23 | + |
| 24 | +for k, v in pi_os_vars.items(): |
| 25 | + locals()[k] = v |
| 26 | + |
| 27 | +for k, v in pi_os_special_vars.items(): |
| 28 | + locals()[k] = v |
| 29 | + |
| 30 | +#debugenv = locals().copy() |
| 31 | +#pprint.pprint (debugenv) |
0 commit comments