Env oauth url (#1030)

Overriding settings in DB using environment variable in docker
This commit is contained in:
benshalev849 2021-11-05 18:22:38 +02:00 committed by GitHub
parent c7b4aa3434
commit 3081036c2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -5,6 +5,9 @@ SQLALCHEMY_DATABASE_URI = 'sqlite:////data/powerdns-admin.db'
legal_envvars = (
'SECRET_KEY',
'OIDC_OAUTH_API_URL',
'OIDC_OAUTH_TOKEN_URL',
'OIDC_OAUTH_AUTHORIZE_URL',
'BIND_ADDRESS',
'PORT',
'LOG_LEVEL',

View File

@ -268,16 +268,23 @@ class Setting(db.Model):
def get(self, setting):
if setting in self.defaults:
result = self.query.filter(Setting.name == setting).first()
if setting.upper() in current_app.config:
result = current_app.config[setting.upper()]
else:
result = self.query.filter(Setting.name == setting).first()
if result is not None:
return strtobool(result.value) if result.value in [
if hasattr(result,'value'):
result = result.value
return strtobool(result) if result in [
'True', 'False'
] else result.value
] else result
else:
return self.defaults[setting]
else:
current_app.logger.error('Unknown setting queried: {0}'.format(setting))
def get_records_allow_to_edit(self):
return list(
set(self.get_forward_records_allow_to_edit() +