correct missing cookie behavior
This commit is contained in:
parent
8d5fcbee7f
commit
37ac0a471a
11
main.go
11
main.go
|
@ -1,17 +1,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "flag"
|
|
||||||
"fmt"
|
|
||||||
// "html"
|
|
||||||
"code.google.com/p/go-uuid/uuid"
|
"code.google.com/p/go-uuid/uuid"
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
// "fmt"
|
"fmt"
|
||||||
"github.com/golang/groupcache/lru"
|
"github.com/golang/groupcache/lru"
|
||||||
// "html"
|
|
||||||
"github.com/namsral/flag"
|
"github.com/namsral/flag"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -85,12 +81,11 @@ func envOrFlag(name, help string) string {
|
||||||
|
|
||||||
func redirectIfCookieMissing(handler http.Handler, ssoSecret, cookieSecret, ssoUri string) http.Handler {
|
func redirectIfCookieMissing(handler http.Handler, ssoSecret, cookieSecret, ssoUri string) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
cookie, _ := r.Cookie("__discourse_proxy")
|
cookie, err := r.Cookie("__discourse_proxy")
|
||||||
|
|
||||||
var username string
|
var username string
|
||||||
var err error
|
|
||||||
|
|
||||||
if cookie != nil {
|
if err == nil && cookie != nil {
|
||||||
username, err = parseCookie(cookie.Value, cookieSecret)
|
username, err = parseCookie(cookie.Value, cookieSecret)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue