Pass redirect field in login page to get a proper redirect

This commit is contained in:
Manuel de Brito Fontes 2017-10-05 01:55:42 -03:00
parent 23916be991
commit 23af068e17
4 changed files with 40 additions and 2 deletions

View file

@ -22,6 +22,7 @@ import (
"encoding/json"
"fmt"
"net"
"net/url"
"os"
"os/exec"
"strconv"
@ -153,6 +154,7 @@ var (
"buildForwardedFor": buildForwardedFor,
"trustHTTPHeaders": trustHTTPHeaders,
"trustProxyProtocol": trustProxyProtocol,
"buildAuthSignURL": buildAuthSignURL,
}
)
@ -690,3 +692,23 @@ func trustProxyProtocol(input interface{}) bool {
return conf.Cfg.RealClientFrom == "tcp-proxy" ||
(conf.Cfg.RealClientFrom == "auto" && conf.Cfg.UseProxyProtocol)
}
func buildAuthSignURL(input interface{}) string {
s, ok := input.(string)
if !ok {
glog.Errorf("expected an 'string' type but %T was returned", input)
return ""
}
u, _ := url.Parse(s)
q := u.Query()
if len(q) == 0 {
return fmt.Sprintf("%v?rd=$request_uri", s)
}
if q.Get("rd") != "" {
return s
}
return fmt.Sprintf("%v&rd=$request_uri", s)
}