aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2019-01-26 10:24:50 -0800
committerChristine Dodrill <me@christine.website>2019-01-26 10:24:50 -0800
commit26cc8779330456758d4eb560cb24975f4e53bce0 (patch)
tree8805b254ac98635909908c119c2a5ce97556c7b4
parent70d8427761be27d022dbbe56537c978bca316c5d (diff)
downloadx-26cc8779330456758d4eb560cb24975f4e53bce0.tar.xz
x-26cc8779330456758d4eb560cb24975f4e53bce0.zip
idp/idpmiddleware: salt better
-rw-r--r--idp/idpmiddleware/middleware.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/idp/idpmiddleware/middleware.go b/idp/idpmiddleware/middleware.go
index 99733f4..3ffb700 100644
--- a/idp/idpmiddleware/middleware.go
+++ b/idp/idpmiddleware/middleware.go
@@ -24,6 +24,8 @@ func hash(data string, salt string) string {
return fmt.Sprintf("%x", output)
}
+var bootTime = time.Now()
+
func verify(ctx context.Context, idpServer, state, code string) *http.Request {
u, err := url.Parse(idpServer)
if err != nil {
@@ -109,7 +111,7 @@ func Protect(idpServer, me, selfURL string) func(next http.Handler) http.Handler
ln.Log(ctx, ln.Info("setting cookie"))
http.SetCookie(w, &http.Cookie{
Name: "within-x-idpmiddleware",
- Value: hash(me, idpServer),
+ Value: hash(me+bootTime.String(), idpServer),
HttpOnly: true,
Expires: time.Now().Add(900 * time.Hour),
Path: "/",
@@ -127,7 +129,7 @@ func Protect(idpServer, me, selfURL string) func(next http.Handler) http.Handler
}
cookie, err := r.Cookie("within-x-idpmiddleware")
- if err != nil || cookie.Value != hash(me, idpServer) {
+ if err != nil || cookie.Value != hash(me+bootTime.String(), idpServer) {
u, err := url.Parse(idpServer)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)