Complete Golang Gin login page with Recaptcha and JWT
Installation
Get your recaptcha keys:
Now you have a "site key" and a "secret key".
On your console, set the environment variables:
$ export RECAPTCHA_SECRET=your-google-recaptcha-secret-key
$ export GLOBAL_SIGNING_KEY=your-supersecret-signing-key
$ export SERVER_DOMAIN=127.0.0.1
$ export SERVER_PORT=:8080 # ":8080" in debug mode; "" in production
$ export SSL_ENABLED=false # false in debug mode; true in production
Inside login.html
(line 140), add your site key (data-sitekey
) value.
Inside main.go
, inside the checkLoginCredentials
function, add a call to your db to validate the user and password.
Run
go run main.go
In your browser: