{"id":21237525,"url":"https://github.com/michaelbull/spring-boot-starter-recaptcha","last_synced_at":"2025-07-10T18:32:12.175Z","repository":{"id":57726640,"uuid":"219353470","full_name":"michaelbull/spring-boot-starter-recaptcha","owner":"michaelbull","description":"Spring Boot starter for Google's reCAPTCHA v3.","archived":false,"fork":false,"pushed_at":"2021-12-28T17:05:59.000Z","size":137,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T16:11:08.656Z","etag":null,"topics":["boot","captcha","mvc","recaptcha","spring","v3","validation","validator","verify"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michaelbull.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-03T19:25:19.000Z","updated_at":"2023-11-10T03:20:21.000Z","dependencies_parsed_at":"2022-09-26T21:50:57.247Z","dependency_job_id":null,"html_url":"https://github.com/michaelbull/spring-boot-starter-recaptcha","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/michaelbull/spring-boot-starter-recaptcha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelbull%2Fspring-boot-starter-recaptcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelbull%2Fspring-boot-starter-recaptcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelbull%2Fspring-boot-starter-recaptcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelbull%2Fspring-boot-starter-recaptcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaelbull","download_url":"https://codeload.github.com/michaelbull/spring-boot-starter-recaptcha/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelbull%2Fspring-boot-starter-recaptcha/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264631213,"owners_count":23640941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boot","captcha","mvc","recaptcha","spring","v3","validation","validator","verify"],"created_at":"2024-11-21T00:19:13.642Z","updated_at":"2025-07-10T18:32:11.849Z","avatar_url":"https://github.com/michaelbull.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring Boot reCAPTCHA v3 Starter\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.michael-bull.spring-boot-starter-recaptcha/spring-boot-starter-recaptcha.svg)](https://search.maven.org/search?q=g:com.michael-bull.spring-boot-starter-recaptcha) [![CI Status](https://github.com/michaelbull/spring-boot-starter-recaptcha/workflows/ci/badge.svg)](https://github.com/michaelbull/spring-boot-starter-recaptcha/actions?query=workflow%3Aci) [![License](https://img.shields.io/github/license/michaelbull/spring-boot-starter-recaptcha.svg)](https://github.com/michaelbull/spring-boot-starter-recaptcha/blob/master/LICENSE)\n\nSpring Boot starter for Google's [reCAPTCHA v3][recaptcha-v3].\n\n## Installation\n\n```groovy\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation(\"com.michael-bull.spring-boot-starter-recaptcha:spring-boot-starter-recaptcha:1.0.4\")\n}\n```\n\n## Getting Started\n\n#### 1. Register reCAPTCHA v3 keys\n\nRegister your application on the [key registration page][recaptcha-v3-keys].\n\n#### 2. Add the configuration properties to your `application.yaml`:\n\n```yaml\nrecaptcha.keys:\n  site: \"\u003cyour site key\u003e\"\n  secret: \"\u003cyour secret key\u003e\"\n```\n\n#### 3. Model the form that recaptcha exists on:\n\n```kotlin\nclass RegisterForm {\n\n    var recaptchaAction: String? = \"register\"\n\n    var recaptchaResponseToken: String? = null\n\n    @Email\n    var email: String? = null\n}\n```\n\n\n#### 4. Add a validator for your form:\n\n```kotlin\n@Component\n@RequestScope\nclass RegisterFormValidator @Inject constructor(\n    private val request: HttpServletRequest,\n    private val recaptchaValidator: RecaptchaValidator\n) : Validator {\n\n    override fun supports(clazz: Class\u003c*\u003e): Boolean {\n        return RegisterForm::class.java.isAssignableFrom(clazz)\n    }\n\n    override fun validate(target: Any, errors: Errors) {\n        val form = target as RecoverAccountForm\n        val action = form.recaptchaAction\n        val responseToken = form.recaptchaResponseToken\n\n        recaptchaValidator\n            .validate(\"recaptchaResponseToken\", request, action, responseToken, errors)\n            .onSuccess { (_, response) -\u003e checkResponse(response, errors) }\n    }\n\n    private fun checkResponse(response: SiteVerifyResponse, errors: Errors) {\n        val score = response.score\n\n        if (score != null \u0026\u0026 score \u003c 0.2) {\n            errors.rejectValue(\"recaptchaResponseToken\", \"Score too low\")\n        }\n    }\n}\n```\n\n#### 5. Bind the validator in your `Controller`:\n\n```kotlin\n@Controller\nclass RegisterController @Inject constructor(\n    private val formValidator: RegisterFormValidator\n) {\n\n    @InitBinder(\"form\")\n    fun initFormBinder(binder: WebDataBinder) {\n        binder.addValidators(formValidator)\n    }\n\n    /* get and post handlers... */\n}\n```\n\n## I18n\n\nError codes generated by the RecaptchaValidator can be internationalized by\nadding the following entries to your `messages.properties`:\n\n```properties\ncaptcha.error.actionMissing=Captcha action missing.\ncaptcha.error.incomplete=Captcha incomplete.\ncaptcha.error.request=Failed to submit captcha.\ncaptcha.error.responseMissing=No response from captcha service.\ncaptcha.error.response=Error response from captcha service.\ncaptcha.error.failed=Captcha failed. Please try again.\ncaptcha.error.actionMismatch=Captcha action mismatch.\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on [GitHub][github].\n\n## License\n\nThis project is available under the terms of the ISC license. See the\n[`LICENSE`](LICENSE) file for the copyright information and licensing terms.\n\n[recaptcha-v3]: https://developers.google.com/recaptcha/docs/v3\n[recaptcha-v3-keys]: https://g.co/recaptcha/v3\n[github]: https://github.com/michaelbull/spring-boot-starter-recaptcha\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelbull%2Fspring-boot-starter-recaptcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelbull%2Fspring-boot-starter-recaptcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelbull%2Fspring-boot-starter-recaptcha/lists"}