Skip to content

Commit

Permalink
feat: HCaptcha Middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
ReneWerner87 committed Apr 19, 2024
1 parent d4f8f47 commit d126e50
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions hcaptcha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ id: hcaptcha

# HCaptcha


![Release](https://img.shields.io/github/v/tag/gofiber/contrib?filter=hcaptcha*)
[![Discord](https://img.shields.io/discord/704680098577514527?style=flat&label=%F0%9F%92%AC%20discord&color=00ACD7)](https://gofiber.io/discord)
![Test](https://github.com/gofiber/contrib/workflows/Tests/badge.svg)
Expand Down Expand Up @@ -33,17 +32,18 @@ go get -u github.com/gofiber/contrib/hcaptcha
```

## Signature

```go
hcaptcha.New(config hcaptcha.Config) fiber.Handler
```

## Config

| Property | Type | Description | Default |
|:----------------|:----------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------|
| SecretKey | `string` | The secret key you got from HCaptcha admin panel. This field must not be empty. | `""` |
| ResponseKeyFunc | `func(fiber.Ctx) (string, error)` | ResponseKeyFunc should return the token that captcha provides upon successful solving. By default it gets the token from the body by parsing a JSON request and returns the `hcaptcha_token` field. | `hcaptcha.DefaultResponseKeyFunc` |
| SiteVerifyURL | `string` | It uses this API resource for token authentication. | `https://api.hcaptcha.com/siteverify` |
| Property | Type | Description | Default |
|:----------------|:----------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------|
| SecretKey | `string` | The secret key you obtained from the HCaptcha admin panel. This field must not be empty. | `""` |
| ResponseKeyFunc | `func(fiber.Ctx) (string, error)` | ResponseKeyFunc should return the token that captcha provides upon successful solving. By default, it gets the token from the body by parsing a JSON request and returns the `hcaptcha_token` field. | `hcaptcha.DefaultResponseKeyFunc` |
| SiteVerifyURL | `string` | This property specifies the API resource used for token authentication. | `https://api.hcaptcha.com/siteverify` |

## Example

Expand All @@ -52,13 +52,13 @@ package main

import (
"github.com/gofiber/contrib/hcaptcha"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v3"
"log"
)

const (
TestSecretKey = "0x0000000000000000000000000000000000000000"
TestSiteKey = "20000000-ffff-ffff-ffff-000000000002"
TestSecretKey = "0x0000000000000000000000000000000000000000"
TestSiteKey = "20000000-ffff-ffff-ffff-000000000002"
)

func main() {
Expand All @@ -80,4 +80,4 @@ func main() {

log.Fatal(app.Listen(":3000"))
}
```
```

0 comments on commit d126e50

Please sign in to comment.