mirror of
https://github.com/nkanaev/yarr.git
synced 2025-10-13 23:39:58 +00:00
auth cookie directives
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
- (new) serve on unix socket (thanks to @rvighne)
|
- (new) serve on unix socket (thanks to @rvighne)
|
||||||
- (fix) smooth scrolling on iOS (thanks to gatheraled)
|
- (fix) smooth scrolling on iOS (thanks to gatheraled)
|
||||||
|
- (etc) cookie security measures (thanks to Tom Fitzhenry)
|
||||||
|
|
||||||
# v2.5 (2025-03-26)
|
# v2.5 (2025-03-26)
|
||||||
|
|
||||||
|
@@ -7,7 +7,6 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func IsAuthenticated(req *http.Request, username, password string) bool {
|
func IsAuthenticated(req *http.Request, username, password string) bool {
|
||||||
@@ -26,8 +25,10 @@ func Authenticate(rw http.ResponseWriter, username, password, basepath string) {
|
|||||||
http.SetCookie(rw, &http.Cookie{
|
http.SetCookie(rw, &http.Cookie{
|
||||||
Name: "auth",
|
Name: "auth",
|
||||||
Value: username + ":" + secret(username, password),
|
Value: username + ":" + secret(username, password),
|
||||||
Expires: time.Now().Add(time.Hour * 24 * 7), // 1 week,
|
MaxAge: 604800, // 1 week
|
||||||
Path: basepath,
|
Path: basepath,
|
||||||
|
Secure: true,
|
||||||
|
SameSite: http.SameSiteLaxMode,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user