mirror of
https://github.com/Luzifer/nginx-sso.git
synced 2024-12-20 04:41:17 +00:00
Fix: Use cookie for redirects after oAuth flow
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
72187c5f64
commit
8af1eeaa4c
1 changed files with 14 additions and 1 deletions
15
redirect.go
15
redirect.go
|
@ -3,16 +3,25 @@ package main
|
|||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func getRedirectURL(r *http.Request, fallback string) (string, error) {
|
||||
var (
|
||||
redirURL string
|
||||
params url.Values
|
||||
redirURL string
|
||||
sessURL string
|
||||
)
|
||||
|
||||
if cookieStore != nil {
|
||||
sess, _ := cookieStore.Get(r, strings.Join([]string{mainCfg.Cookie.Prefix, "main"}, "-"))
|
||||
if s, ok := sess.Values["go"].(string); ok {
|
||||
sessURL = s
|
||||
}
|
||||
}
|
||||
|
||||
switch {
|
||||
case r.URL.Query().Get("go") != "":
|
||||
// We have a GET request, use "go" query param
|
||||
|
@ -24,6 +33,10 @@ func getRedirectURL(r *http.Request, fallback string) (string, error) {
|
|||
redirURL = r.FormValue("go")
|
||||
params = url.Values{} // No need to read other form fields
|
||||
|
||||
case sessURL != "":
|
||||
redirURL = sessURL
|
||||
params = url.Values{}
|
||||
|
||||
default:
|
||||
// No URL specified, use specified fallback URL
|
||||
return fallback, nil
|
||||
|
|
Loading…
Reference in a new issue