Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

google reCaptcha configuration for multiple website pattern

karthik4
Level 2
Level 2

Hello, 

I have 3 Websites hosted on my AEM platform, each using Google reCaptcha.  Each website are completely different, but they use the similar service Google reCaptcha service. Each website has their own separate "public key".

 

What is the best way to configure each website, so that the keys are only expose to specific websites? OSGI configurations, configuration on the recaptcha component, configuration in page properties, etc?

 

Whats the best practice, please help?

1 Accepted Solution
andyshreve
Correct answer by
Level 4
Level 4

A basic approach that I've seen used successfully is to put a site-specific property at the root page of the site, like at /content/site1/en_us, and then adjust the component to inherit that property using InheritanceValueMap like this:

InheritanceValueMap ivmap = new ComponentInheritanceValueMap(resource);
String captchakey = ivmap.getInherited("captchakey", String.class);

 

View solution in original post

0 Replies
andyshreve
Correct answer by
Level 4
Level 4

A basic approach that I've seen used successfully is to put a site-specific property at the root page of the site, like at /content/site1/en_us, and then adjust the component to inherit that property using InheritanceValueMap like this:

InheritanceValueMap ivmap = new ComponentInheritanceValueMap(resource);
String captchakey = ivmap.getInherited("captchakey", String.class);

 

Arun_Patidar
Community Advisor
Community Advisor

you can go for context-aware config as well or stores as OSGi factory config and read factory config based on site.

 

CAC

https://sling.apache.org/documentation/bundles/context-aware-configuration/context-aware-configurati...

 

karthik4
Level 2
Level 2

I was to avoid the context-aware config because of many restrictions do you think @andyshreve's solution is a better and best practice solution? context-aware config is not widely used by the community right?

Arun_Patidar
Community Advisor
Community Advisor
yes, one of the solution is storing keys at site root page property and use it using inheritance but make sure author does not accidentally deleted those values, hide those properties for content author and keep it visible only for admin/super author. This can be done using rendercondition
karthik4
Level 2
Level 2
Thank you, but what is the best practice? context-aware config or page property?
Arun_Patidar
Community Advisor
Community Advisor
It depends, if you have different keys for different environment then you need context aware config editor(https://wcm.io/caconfig/) but if you manage at root page level then you can manage without having external editor but make sure author should not edit keys. we used config editor so for me I would go for CAC.