Add support for openid with github and facebook

This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-10-04 11:40:56 -03:00
parent eebe638227
commit 4c034812d2
25 changed files with 712 additions and 251 deletions

View File

@@ -10,7 +10,6 @@ import (
"github.com/play-with-docker/play-with-docker/config"
"github.com/play-with-docker/play-with-docker/provisioner"
"github.com/play-with-docker/play-with-docker/recaptcha"
)
type NewSessionResponse struct {
@@ -20,10 +19,16 @@ type NewSessionResponse struct {
func NewSession(rw http.ResponseWriter, req *http.Request) {
req.ParseForm()
if !recaptcha.IsHuman(req, rw) {
// User it not a human
rw.WriteHeader(http.StatusForbidden)
return
userId := ""
if len(config.Providers) > 0 {
cookie, err := ReadCookie(req)
if err != nil {
// User it not a human
rw.WriteHeader(http.StatusForbidden)
return
}
userId = cookie.Id
}
reqDur := req.Form.Get("session-duration")
@@ -45,7 +50,7 @@ func NewSession(rw http.ResponseWriter, req *http.Request) {
}
duration := config.GetDuration(reqDur)
s, err := core.SessionNew(duration, stack, stackName, imageName)
s, err := core.SessionNew(userId, duration, stack, stackName, imageName)
if err != nil {
if provisioner.OutOfCapacity(err) {
http.Redirect(rw, req, "/ooc", http.StatusFound)