From e6e81e526d78359838e56837e3aead0028ae80f0 Mon Sep 17 00:00:00 2001 From: Parminder Singh Date: Fri, 2 Mar 2018 20:53:01 +0530 Subject: [PATCH] Added the config to fallback handler --- .../dendrite/clientapi/routing/auth_fallback.go | 14 ++++++++++---- .../dendrite/clientapi/routing/routing.go | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/clientapi/routing/auth_fallback.go b/src/github.com/matrix-org/dendrite/clientapi/routing/auth_fallback.go index 0e93ef801..9d087a20d 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/routing/auth_fallback.go +++ b/src/github.com/matrix-org/dendrite/clientapi/routing/auth_fallback.go @@ -17,6 +17,8 @@ package routing import ( "html/template" "net/http" + + "github.com/matrix-org/dendrite/common/config" ) // RecaptchaTemplate is template for recaptcha auth @@ -87,14 +89,18 @@ if (window.onAuthDone) { ` // AuthFallback implements GET on /auth/{authType}/fallback/web?session={sessionID} -func AuthFallback(w http.ResponseWriter, req *http.Request, authType string, sessionID string) { +// TODO: Handle POST requests too +func AuthFallback( + w http.ResponseWriter, req *http.Request, authType string, sessionID string, + cfg config.Dendrite, +) { if req.Method == "GET" { t := template.Must(template.New("response").Parse(RECAPTCHA_TEMPLATE)) data := map[string]string{ - "MyUrl": "TODO", - "Session": "TODO", - "SiteKey": "TODO", + "MyUrl": req.URL.String(), + "Session": sessionID, + "SiteKey": cfg.Matrix.RecaptchaPublicKey, } if err := t.Execute(w, data); err != nil { diff --git a/src/github.com/matrix-org/dendrite/clientapi/routing/routing.go b/src/github.com/matrix-org/dendrite/clientapi/routing/routing.go index 9ae40aa80..03e693c75 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/routing/routing.go +++ b/src/github.com/matrix-org/dendrite/clientapi/routing/routing.go @@ -177,7 +177,7 @@ func Setup( r0mux.Handle("/auth/{authType}/fallback/web?session={sessionID}", common.MakeHtmlAPI("authfallback", func(w http.ResponseWriter, req *http.Request) util.JSONResponse { vars := mux.Vars(req) - return AuthFallback(w, req, vars["authType"], vars["sessionID"]) + return AuthFallback(w, req, vars["authType"], vars["sessionID"], cfg) }), ).Methods("GET", "OPTIONS")