-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
30 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/justinas/nosurf" | ||
"net/http" | ||
) | ||
|
||
func WriteToConsole(next http.Handler) http.Handler { | ||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
fmt.Println("Hit the page") | ||
next.ServeHTTP(w, r) | ||
}) | ||
} | ||
|
||
// NoSurf is the csrf protection middleware | ||
func NoSurf(next http.Handler) http.Handler { | ||
csrfHandler := nosurf.New(next) | ||
|
||
csrfHandler.SetBaseCookie(http.Cookie{ | ||
HttpOnly: true, | ||
Path: "/", | ||
Secure: false, | ||
Secure: app.InProduction, | ||
SameSite: http.SameSiteLaxMode, | ||
}) | ||
return csrfHandler | ||
} | ||
|
||
// SessionLoad loads and saves session data for current request | ||
func SessionLoad(next http.Handler) http.Handler { | ||
return session.LoadAndSave(next) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters