From 914932418b3e00129b1fb3a43198e06f632b3362 Mon Sep 17 00:00:00 2001 From: Alex Geno Date: Sat, 16 Sep 2023 19:44:10 +0300 Subject: [PATCH] Add recipe for Phone Verification Bundle (#1541) * alexgeno/phone-verification-bundle/1.0 receipt * Delete post-install.txt * Fix check error: Text files should end with a newline * Fix check error: Wrong bundle name * Manifest.json improvements * Manifest.json improvements * Modify packages/snc_redis.yaml to set default redis connection * Modify packages/snc_redis.yaml to set default redis connection * Add routes * Add routes --- .../alex_geno_phone_verification.yaml | 19 +++++++++++++ .../routes/alex_geno_phone_verification.yaml | 8 ++++++ .../1.0/manifest.json | 27 +++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 alexgeno/phone-verification-bundle/1.0/config/packages/alex_geno_phone_verification.yaml create mode 100644 alexgeno/phone-verification-bundle/1.0/config/routes/alex_geno_phone_verification.yaml create mode 100644 alexgeno/phone-verification-bundle/1.0/manifest.json diff --git a/alexgeno/phone-verification-bundle/1.0/config/packages/alex_geno_phone_verification.yaml b/alexgeno/phone-verification-bundle/1.0/config/packages/alex_geno_phone_verification.yaml new file mode 100644 index 000000000..3999703ef --- /dev/null +++ b/alexgeno/phone-verification-bundle/1.0/config/packages/alex_geno_phone_verification.yaml @@ -0,0 +1,19 @@ +alex_geno_phone_verification: + storage: + driver: redis # redis || mongodb + redis: + connection: default + mongodb: + connection: default + sender: + transport: vonage + manager: + otp: + length: '%env(int:PHONE_VERIFICATION_OTP_LENGTH)%' + rate_limits: + initiate: #for every 'to' no more than 'count' initiations over 'period_secs' seconds + period_secs: '%env(int:PHONE_VERIFICATION_RATE_LIMIT_INITIATE_PERIOD_SECS)%' + count: '%env(int:PHONE_VERIFICATION_RATE_LIMIT_INITIATE_COUNT)%' + complete: #for every 'to' no more than 'count' failed completions over 'period_secs' seconds + period_secs: '%env(int:PHONE_VERIFICATION_RATE_LIMIT_COMPLETE_PERIOD_SECS)%' # this is also the expiration period for OTP + count: '%env(int:PHONE_VERIFICATION_RATE_LIMIT_COMPLETE_COUNT)%' diff --git a/alexgeno/phone-verification-bundle/1.0/config/routes/alex_geno_phone_verification.yaml b/alexgeno/phone-verification-bundle/1.0/config/routes/alex_geno_phone_verification.yaml new file mode 100644 index 000000000..4b6c30d07 --- /dev/null +++ b/alexgeno/phone-verification-bundle/1.0/config/routes/alex_geno_phone_verification.yaml @@ -0,0 +1,8 @@ +phone_verification_initiate: + path: /phone-verification/initiate/{to} + controller: AlexGeno\PhoneVerificationBundle\Controller\PhoneVerificationController::initiate + methods: POST +phone_verification_complete: + path: /phone-verification/complete/{to}/{otp} + controller: AlexGeno\PhoneVerificationBundle\Controller\PhoneVerificationController::complete + methods: POST diff --git a/alexgeno/phone-verification-bundle/1.0/manifest.json b/alexgeno/phone-verification-bundle/1.0/manifest.json new file mode 100644 index 000000000..de95a00bd --- /dev/null +++ b/alexgeno/phone-verification-bundle/1.0/manifest.json @@ -0,0 +1,27 @@ +{ + "bundles": { + "AlexGeno\\PhoneVerificationBundle\\AlexGenoPhoneVerificationBundle": ["all"] + }, + "copy-from-recipe": { + "config/": "%CONFIG_DIR%/" + }, + "env": { + "#0": "1000..9999", + "PHONE_VERIFICATION_OTP_LENGTH": "4", + "#1": "for every 'to' no more than 10 initiations over 24 hours", + "PHONE_VERIFICATION_RATE_LIMIT_INITIATE_PERIOD_SECS": "86400", + "PHONE_VERIFICATION_RATE_LIMIT_INITIATE_COUNT": "10", + "#2": "for every 'to' no more than 5 failed completions over 5 minutes", + "PHONE_VERIFICATION_RATE_LIMIT_COMPLETE_PERIOD_SECS": "300", + "PHONE_VERIFICATION_RATE_LIMIT_COMPLETE_COUNT": "5" + }, + "add-lines": [ + { + "file": "config/packages/snc_redis.yaml", + "position": "after_target", + "warn_if_missing": true, + "target": " clients:", + "content": " default:\n type: predis\n alias: default\n dsn: \"%env(REDIS_URL)%\"" + } + ] +}