Skip to content

Commit b87411e

Browse files
Add captcha
1 parent cc400c8 commit b87411e

3 files changed

Lines changed: 34 additions & 1 deletion

File tree

website/docs/userguide/authentication/forms.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,37 @@ Any change you make will instantly refresh the Preview. Remember: saving CSS cha
126126
### Editing the translations
127127

128128
Click **Translations** in the Actions panel to view the available translations.
129-
Use the Success messages and Error messages tabs to edit the corresponding translations.
129+
Use the Success messages and Error messages tabs to edit the corresponding translations.
130+
131+
## Adding Captcha
132+
133+
In authentication or registration forms, it is possible to add a "Captcha" to verify whether the user is a human and not a bot.
134+
To add one, navigate to the graphical editor of a form and drag the component into the form.
135+
136+
Currently, only the reCAPTCHA2 type is supported. You can create one at the following URL: https://www.google.com/recaptcha/admin/create.
137+
138+
Once the Captcha is created, you will need to retrieve the `site key` and the `secret key` to configure the Captcha component.
139+
140+
![reCAPTCHA2](./imgs/reCAPTCHA2.png)
141+
142+
In the properties of the Captcha component, enter the `site key`, then save and publish the form changes.
143+
144+
Here is what the Login and Password authentication form will look like when the Captcha is properly configured:
145+
146+
![pwd witch captcha](./imgs/pwdWithCaptcha.png)
147+
148+
When a form containing the Captcha is submitted by the user, the `CaptchaValue` element is sent to the backend along with the Captcha value.
149+
150+
This value must be validated by your identity server in the backend.
151+
152+
To enable this validation, edit the `Program.cs` file and call the `EnableV2Recaptcha` method. You must pass the `secret key` as a parameter.
153+
154+
Here is an example configuration:
155+
156+
```csharp title="Program.cs"
157+
webApplicationBuilder.AddSidIdentityServer()
158+
.EnableV2Recaptcha(c => {
159+
s.Secret = "<secret>";
160+
})
161+
```
162+
"
22.8 KB
Loading
34.8 KB
Loading

0 commit comments

Comments
 (0)