From 378d6cfb8b351e6bfa3f730846d676807880fb4b Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 3 Apr 2023 15:27:04 +0200 Subject: [PATCH] (bug) unable to write the configuration of the auth provider --- CHANGELOG.md | 2 ++ lib/provider_config.rb | 18 ++++++++++++------ scripts/mount-auth-provider.sh | 3 ++- setup/docker-compose.yml | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f928f5dc..891d2fc6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog Fab-manager +- Fix a bug: unable to write the configuration of the auth provider + ## v6.0.0 2023 April 03 - Updated ruby to 3.2 diff --git a/lib/provider_config.rb b/lib/provider_config.rb index 47bbf4285..7d014e56f 100644 --- a/lib/provider_config.rb +++ b/lib/provider_config.rb @@ -4,13 +4,10 @@ class ProviderConfig def initialize @config = if File.exist?('config/auth_provider.yml') - YAML.safe_load_file('config/auth_provider.yml').with_indifferent_access + content = YAML.safe_load_file('config/auth_provider.yml') + content.blank? ? simple_provider : content.with_indifferent_access else - { - providable_type: 'DatabaseProvider', - name: 'DatabaseProvider::SimpleAuthProvider', - strategy_name: 'database-simpleauthprovider' - } + simple_provider end end @@ -67,4 +64,13 @@ class ProviderConfig item end + + # @return [Hash{Symbol->String}] + def simple_provider + { + providable_type: 'DatabaseProvider', + name: 'DatabaseProvider::SimpleAuthProvider', + strategy_name: 'database-simpleauthprovider' + } + end end diff --git a/scripts/mount-auth-provider.sh b/scripts/mount-auth-provider.sh index cb1b8dd67..b15385f78 100644 --- a/scripts/mount-auth-provider.sh +++ b/scripts/mount-auth-provider.sh @@ -20,9 +20,10 @@ config() add_mount() { if [[ ! $(yq eval ".services.$SERVICE.volumes.[] | select (. == \"*auth_provider.yml\")" docker-compose.yml) ]]; then + touch ./config/auth_provider.yml # change docker-compose.yml permissions for fix yq can't modify file issue chmod 666 docker-compose.yml - yq -i eval ".services.$SERVICE.volumes += [\"./config/auth_provider.yml:/usr/src/app/auth_provider.yml\"]" docker-compose.yml + yq -i eval ".services.$SERVICE.volumes += [\"./config/auth_provider.yml:/usr/src/app/config/auth_provider.yml\"]" docker-compose.yml chmod 644 docker-compose.yml fi } diff --git a/setup/docker-compose.yml b/setup/docker-compose.yml index 480326d2f..a2bbddc18 100644 --- a/setup/docker-compose.yml +++ b/setup/docker-compose.yml @@ -19,7 +19,7 @@ services: - ./log:/var/log/supervisor - ./plugins:/usr/src/app/plugins - ./accounting:/usr/src/app/accounting - - ./config/auth_provider.yml:/usr/src/app/auth_provider.yml + - ./config/auth_provider.yml:/usr/src/app/config/auth_provider.yml depends_on: - postgres - redis