Skip to content
Snippets Groups Projects
Verified Commit 75d0aa20 authored by Andrej Shadura's avatar Andrej Shadura
Browse files

Generate the SSO config from the environment variables


The generator requires Python 3 and pyyaml

Signed-off-by: Andrej Shadura's avatarAndrej Shadura <andrew.shadura@collabora.co.uk>
parent d4ae81d1
Branches
No related tags found
1 merge request!21OBS SSO implementation
......@@ -43,7 +43,7 @@ RUN \
sed -i 's/stable/stretch/g' /etc/apt/sources.list \
&& echo "obs-api obs-api/dbconfig-install boolean false" | debconf-set-selections \
&& apt-get update \
&& apt-get -y install locales supervisor curl ca-certificates
&& apt-get -y install locales supervisor curl ca-certificates python3-yaml
COPY --from=builder /tmp/obs-api*.deb /tmp
......
#!/usr/bin/python3
import yaml
import os
CONFIG_LOCATION='/usr/share/obs/api/config/auth.yml'
def parse_method(method: str):
for k, v in os.environ.items():
prefix = 'OBS_SSO_' + method.upper().replace('-', '_') + '_'
if k.startswith(prefix):
opt = k.replace(prefix, '').lower()
yield opt, v
def reorder_options(options: dict):
new_options = {}
client_options = {}
for k, v in options.items():
if k.startswith('client_options_'):
client_options[k.replace('client_options_', '')] = v
else:
new_options[k] = v
if client_options:
new_options['client_options'] = client_options
return new_options
def generate_yaml():
methods = os.environ['OBS_SSO_METHODS'].split()
config = {}
for method in methods:
options = reorder_options(dict(parse_method(method)))
config[method] = options
with open(CONFIG_LOCATION, 'w') as f:
yaml.safe_dump(config, stream=f)
if __name__ == "__main__":
if os.environ.get('OBS_SSO_ENABLED') == 'true':
generate_yaml()
......@@ -5,6 +5,7 @@ rm -rfv /run/*
mkdir -m a=rwxt /run/lock
/opt/configure-db.sh
/opt/configure-sso.py
/opt/configure-app.sh
/usr/bin/supervisord -n
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment