From 99ee6e8d884b9d2f1d94d3a48951ecc38d1e0920 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Tue, 9 Apr 2024 19:12:02 +0200 Subject: [PATCH 1/2] Add Apple Pay verification for Stripe --- conf/apple_pay.conf | 4 ++++ config_panel.toml | 13 +++++++++++++ scripts/config | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 conf/apple_pay.conf create mode 100644 config_panel.toml create mode 100644 scripts/config diff --git a/conf/apple_pay.conf b/conf/apple_pay.conf new file mode 100644 index 0000000..3a589c6 --- /dev/null +++ b/conf/apple_pay.conf @@ -0,0 +1,4 @@ +location = /.well-known/apple-developer-merchantid-domain-association { + alias __INSTALL_DIR__; + index apple-developer-merchantid-domain-association =404; +} diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..0d5df3a --- /dev/null +++ b/config_panel.toml @@ -0,0 +1,13 @@ +version = "1.0" + +[main] +name = "Ghost configuration" + + [main.stripe] + name = "Stripe integration" + + [main.stripe.apple_pay] + ask = "Upload the apple-developer-merchantid-domain-association file" + type = "file" + help = "It is provided by Stripe" + bind = "__INSTALL_DIR__/apple_pay.__APP__.conf" diff --git a/scripts/config b/scripts/config new file mode 100644 index 0000000..92739e1 --- /dev/null +++ b/scripts/config @@ -0,0 +1,39 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +ynh_abort_if_errors + +#================================================= +# OVERWRITING VALIDATE STEP +#================================================= +ynh_app_config_apply() { + + if [ -f $install_dir/apple-developer-merchantid-domain-association ] + then + ynh_add_config --template="apple_pay.conf" --destination="/etc/nginx/conf.d/$domain.d/apple_pay.$app.conf" + if [ ! ynh_permission_exists --permission="$app.apple_pay" ]; then + ynh_permission_create --permission="$app.apple_pay" --url="$domain/.well-known/apple-developer-merchantid-domain-association" --allowed=visitors --protected --auth_header=false + fi + else + ynh_secure_remove --file="/etc/nginx/conf.d/$domain.d/apple_pay.$app.conf" + if [ ynh_permission_exists --permission="$app.apple_pay" ]; then + ynh_permission_delete --permission="$app.apple_pay" + fi + fi + + ynh_systemd_action --service_name=nginx --action=reload + _ynh_app_config_apply +} + +#================================================= +# GENERIC FINALIZATION +#================================================= +ynh_app_config_run $1 From 6c6c76a9544011fcce94487759fdeb077851da02 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Tue, 9 Apr 2024 19:58:45 +0200 Subject: [PATCH 2/2] Fixes for Apple Pay integration --- config_panel.toml | 4 ++-- scripts/config | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index 0d5df3a..b390dd5 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -4,10 +4,10 @@ version = "1.0" name = "Ghost configuration" [main.stripe] - name = "Stripe integration" + name = "Stripe integration" [main.stripe.apple_pay] ask = "Upload the apple-developer-merchantid-domain-association file" type = "file" help = "It is provided by Stripe" - bind = "__INSTALL_DIR__/apple_pay.__APP__.conf" + bind = "__INSTALL_DIR__/apple-developer-merchantid-domain-association" diff --git a/scripts/config b/scripts/config index 92739e1..2062015 100644 --- a/scripts/config +++ b/scripts/config @@ -11,29 +11,35 @@ source /usr/share/yunohost/helpers ynh_abort_if_errors +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +domain=$(ynh_app_setting_get --app=$app --key=domain) + #================================================= # OVERWRITING VALIDATE STEP #================================================= ynh_app_config_apply() { + _ynh_app_config_apply if [ -f $install_dir/apple-developer-merchantid-domain-association ] then ynh_add_config --template="apple_pay.conf" --destination="/etc/nginx/conf.d/$domain.d/apple_pay.$app.conf" - if [ ! ynh_permission_exists --permission="$app.apple_pay" ]; then - ynh_permission_create --permission="$app.apple_pay" --url="$domain/.well-known/apple-developer-merchantid-domain-association" --allowed=visitors --protected --auth_header=false + if ! ynh_permission_exists --permission="apple_pay"; then + ynh_permission_create --permission="apple_pay" --url="$domain/.well-known/apple-developer-merchantid-domain-association" --allowed=visitors --protected --auth_header=false fi else ynh_secure_remove --file="/etc/nginx/conf.d/$domain.d/apple_pay.$app.conf" - if [ ynh_permission_exists --permission="$app.apple_pay" ]; then - ynh_permission_delete --permission="$app.apple_pay" + if ynh_permission_exists --permission="apple_pay"; then + ynh_permission_delete --permission="apple_pay" fi fi ynh_systemd_action --service_name=nginx --action=reload - _ynh_app_config_apply } #================================================= # GENERIC FINALIZATION #================================================= -ynh_app_config_run $1 +ynh_app_config_run "$1"