From c889b9b42f3fa21bfde339e86061fc0d3bd28812 Mon Sep 17 00:00:00 2001 From: Alex Rock Ancelet Date: Sun, 3 Jun 2018 20:44:30 +0200 Subject: [PATCH 1/4] Create google/recaptcha recipe --- .../1.1/config/packages/google_recaptcha.yaml | 20 +++++++++++++++++++ google/recaptcha/1.1/manifest.json | 9 +++++++++ 2 files changed, 29 insertions(+) create mode 100644 google/recaptcha/1.1/config/packages/google_recaptcha.yaml create mode 100644 google/recaptcha/1.1/manifest.json diff --git a/google/recaptcha/1.1/config/packages/google_recaptcha.yaml b/google/recaptcha/1.1/config/packages/google_recaptcha.yaml new file mode 100644 index 00000000..8dfce50d --- /dev/null +++ b/google/recaptcha/1.1/config/packages/google_recaptcha.yaml @@ -0,0 +1,20 @@ +services: + + # Inject this service in your controllers/services to verify a submitted captcha. + ReCaptcha\ReCaptcha: + arguments: + $secret: '%env(GOOGLE_RECAPTCHA_SECRET)%' + + # Curl is set here as default transport to communicate with Google servers. + # If you do not have php-curl extension, you can change for a socket or a plain POST request. + # Check out the repository for all other request methods: + # https://github.com/google/recaptcha/tree/master/src/ReCaptcha/RequestMethod + ReCaptcha\RequestMethod\CurlPost: ~ + ReCaptcha\RequestMethod\Curl: ~ + +parameters: + + # As this parameter has to be used on the frontend side, + # you can add this parameter to your Twig globals, + # or inject it manually from your controllers. + google_recaptcha_site_key: '%env(GOOGLE_RECAPTCHA_SITE_KEY)%' diff --git a/google/recaptcha/1.1/manifest.json b/google/recaptcha/1.1/manifest.json new file mode 100644 index 00000000..d43acd8c --- /dev/null +++ b/google/recaptcha/1.1/manifest.json @@ -0,0 +1,9 @@ +{ + "copy-from-recipe": { + "config/": "%CONFIG_DIR%/" + }, + "env": { + "GOOGLE_RECAPTCHA_SITE_KEY": "", + "GOOGLE_RECAPTCHA_SECRET": "" + } +} From e4d2937e3499371f661286142872489700d5a6a8 Mon Sep 17 00:00:00 2001 From: Alex Rock Ancelet Date: Sun, 3 Jun 2018 20:53:39 +0200 Subject: [PATCH 2/4] Use the "container" configurator --- .../1.1/config/packages/google_recaptcha.yaml | 11 +++++------ google/recaptcha/1.1/manifest.json | 3 +++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/google/recaptcha/1.1/config/packages/google_recaptcha.yaml b/google/recaptcha/1.1/config/packages/google_recaptcha.yaml index 8dfce50d..1c46771a 100644 --- a/google/recaptcha/1.1/config/packages/google_recaptcha.yaml +++ b/google/recaptcha/1.1/config/packages/google_recaptcha.yaml @@ -12,9 +12,8 @@ services: ReCaptcha\RequestMethod\CurlPost: ~ ReCaptcha\RequestMethod\Curl: ~ -parameters: - - # As this parameter has to be used on the frontend side, - # you can add this parameter to your Twig globals, - # or inject it manually from your controllers. - google_recaptcha_site_key: '%env(GOOGLE_RECAPTCHA_SITE_KEY)%' +# Uncomment this line if you want to inject the site key to all your Twig templates. +# You can also inject the "google_recaptcha_site_key" container parameter to your controllers. +#twig: +# globals: +# google_recaptcha_site_key: '%google_recaptcha_site_key%' diff --git a/google/recaptcha/1.1/manifest.json b/google/recaptcha/1.1/manifest.json index d43acd8c..e9e7e736 100644 --- a/google/recaptcha/1.1/manifest.json +++ b/google/recaptcha/1.1/manifest.json @@ -5,5 +5,8 @@ "env": { "GOOGLE_RECAPTCHA_SITE_KEY": "", "GOOGLE_RECAPTCHA_SECRET": "" + }, + "container": { + "google_recaptcha_site_key": "%env(GOOGLE_RECAPTCHA_SITE_KEY)%" } } From c3555dbdc5b39f95d26daa4b99db77784361319d Mon Sep 17 00:00:00 2001 From: Alex Rock Ancelet Date: Sun, 3 Jun 2018 21:03:31 +0200 Subject: [PATCH 3/4] Added comments & small guides --- google/recaptcha/1.1/manifest.json | 2 ++ google/recaptcha/1.1/post-install.txt | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 google/recaptcha/1.1/post-install.txt diff --git a/google/recaptcha/1.1/manifest.json b/google/recaptcha/1.1/manifest.json index e9e7e736..f83b67d1 100644 --- a/google/recaptcha/1.1/manifest.json +++ b/google/recaptcha/1.1/manifest.json @@ -3,6 +3,8 @@ "config/": "%CONFIG_DIR%/" }, "env": { + "#1": "To use Google Recaptcha, you must register a site on Recaptcha's admin panel:", + "#2": "https://www.google.com/recaptcha/admin", "GOOGLE_RECAPTCHA_SITE_KEY": "", "GOOGLE_RECAPTCHA_SECRET": "" }, diff --git a/google/recaptcha/1.1/post-install.txt b/google/recaptcha/1.1/post-install.txt new file mode 100644 index 00000000..7ba5b217 --- /dev/null +++ b/google/recaptcha/1.1/post-install.txt @@ -0,0 +1,9 @@ + + Recaptcha setup + + + * Register a site on https://www.google.com/recaptcha/admin + + * Modify your GOOGLE_RECAPTCHA_SITE_KEY and GOOGLE_RECAPTCHA_SECRET config in .env + + * Inject the ReCaptcha\ReCaptcha service when you need to verify a submitted captcha From b86a758aa3320681d6ba192e7056b279cda7a8d9 Mon Sep 17 00:00:00 2001 From: Alex Rock Ancelet Date: Wed, 6 Jun 2018 21:08:31 +0200 Subject: [PATCH 4/4] [Recaptcha] Add RequestMethod interface --- google/recaptcha/1.1/config/packages/google_recaptcha.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/google/recaptcha/1.1/config/packages/google_recaptcha.yaml b/google/recaptcha/1.1/config/packages/google_recaptcha.yaml index 1c46771a..1e9e8caa 100644 --- a/google/recaptcha/1.1/config/packages/google_recaptcha.yaml +++ b/google/recaptcha/1.1/config/packages/google_recaptcha.yaml @@ -9,6 +9,7 @@ services: # If you do not have php-curl extension, you can change for a socket or a plain POST request. # Check out the repository for all other request methods: # https://github.com/google/recaptcha/tree/master/src/ReCaptcha/RequestMethod + ReCaptcha\RequestMethod: '@ReCaptcha\RequestMethod\CurlPost' ReCaptcha\RequestMethod\CurlPost: ~ ReCaptcha\RequestMethod\Curl: ~