Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHF-10012: Map vault accounts individually, UHF-10015: Stage file proxy default URL #239

Merged
merged 3 commits into from
Jul 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions public/sites/default/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,24 +229,30 @@ function drupal_get_env(string|array $variables) : mixed {
}
}
}
$stage_file_proxy_origin = getenv('STAGE_FILE_PROXY_ORIGIN');
$stage_file_proxy_dir = getenv('STAGE_FILE_PROXY_ORIGIN_DIR');

if ($stage_file_proxy_origin = getenv('STAGE_FILE_PROXY_ORIGIN')) {
$config['stage_file_proxy.settings']['origin'] = $stage_file_proxy_origin;
$config['stage_file_proxy.settings']['origin_dir'] = getenv('STAGE_FILE_PROXY_ORIGIN_DIR') ?: 'test';
if ($stage_file_proxy_origin || $stage_file_proxy_dir) {
$config['stage_file_proxy.settings']['origin'] = $stage_file_proxy_origin ?: 'https://stplattaprod.blob.core.windows.net';
$config['stage_file_proxy.settings']['origin_dir'] = $stage_file_proxy_dir;
$config['stage_file_proxy.settings']['hotlink'] = FALSE;
$config['stage_file_proxy.settings']['use_imagecache_root'] = FALSE;
}

// Map API accounts. The value should be a base64 encoded JSON string.
// @see https://github.com/City-of-Helsinki/drupal-module-helfi-api-base/blob/main/documentation/api-accounts.md.
if ($api_accounts = getenv('DRUPAL_API_ACCOUNTS')) {
$config['helfi_api_base.api_accounts']['accounts'] = json_decode(base64_decode($api_accounts), TRUE);
if ($drupal_pubsub_vault = getenv('DRUPAL_PUBSUB_VAULT')) {
$config['helfi_api_base.api_accounts']['vault'][] = [
'id' => 'pubsub',
'plugin' => 'json',
'data' => trim($drupal_pubsub_vault),
];
}

// Map vault accounts. The value should be a base64 encoded JSON string.
// @see https://github.com/City-of-Helsinki/drupal-module-helfi-api-base/blob/main/documentation/api-accounts.md.
if ($vault_accounts = getenv('DRUPAL_VAULT_ACCOUNTS')) {
$config['helfi_api_base.api_accounts']['vault'] = json_decode(base64_decode($vault_accounts), TRUE);
if ($drupal_navigation_vault = getenv('DRUPAL_NAVIGATION_VAULT')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think DRUPAL_PUBSUB_VAULT and DRUPAL_NAVIGATION_VAULT should be added to preflight checks at least on core instances (and DRUPAL_API_ACCOUNTS and DRUPAL_VAULT_ACCOUNTS should be removed).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but we have to add them manually to all.settings.php, since we can't really differentiate instances in settings.php. Unless I am missing something

$config['helfi_api_base.api_accounts']['vault'][] = [
'id' => 'helfi_navigation',
'plugin' => 'authorization_token',
'data' => trim($drupal_navigation_vault),
];
}

// Override session suffix when present.
Expand Down