1
0
mirror of https://github.com/bingohuang/docker-labs.git synced 2025-10-04 01:17:49 +08:00

Validates that user is a human.

Add google recaptcha as an initial page before creating any session.
To configure recaptcha there are 2 environment variables that are needed
`GOOGLE_RECAPTCHA_SITE_KEY` and `GOOGLE_RECAPTCHA_SITE_SECRET`.
The code contains development defaults that should be set in production
to real values.
**NOTICE: Development defaults assume that the domain is `localhost`**
This commit is contained in:
Jonathan Leibiusky @xetorthio
2016-11-15 16:53:44 -03:00
parent 770945ab86
commit af9986c0f8
7 changed files with 140 additions and 1 deletions

BIN
www/assets/large_h.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@@ -27,3 +27,18 @@ md-card-content.terminal {
color: #1da4eb;
text-align: center;
}
.welcome {
background-color: #e7e7e7;
}
.welcome > div {
text-align: center;
}
.g-recaptcha div {
margin-left: auto;
margin-right: auto;
margin-bottom: auto;
margin-top: 50px;
}

27
www/welcome.html Normal file
View File

@@ -0,0 +1,27 @@
{{define "GOOGLE_RECAPTCHA_SITE_KEY"}}
<!doctype html>
<html ng-app="DockerPlay" ng-controller="PlayController">
<head>
<title>Docker Playground</title>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css">
<link rel="stylesheet" href="/assets/style.css" />
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body class="welcome">
<div>
<h1>Welcome!</h1>
<h2>Before starting we need to verify you are a human</h2>
<form id="welcomeForm" method="POST" action="/">
<div class="g-recaptcha" data-callback="iAmHuman" data-sitekey="{{.}}"></div>
</form>
<img src="/assets/large_h.png" />
</div>
<script>
function iAmHuman(resp) {
document.getElementById('welcomeForm').submit();
}
</script>
</body>
</html>
{{end}}