chore(easyauth) remove cookie
This commit is contained in:
parent
ed070dddfa
commit
387b59789b
1 changed files with 0 additions and 27 deletions
27
easyauth.go
27
easyauth.go
|
@ -2,7 +2,6 @@ package auth
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
@ -112,29 +111,3 @@ func (e EasyAuth) AuthHTTPHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
http.Redirect(w, r, redirectUrlString, http.StatusTemporaryRedirect)
|
||||
}
|
||||
|
||||
func getCookie(w http.ResponseWriter, r *http.Request, name string) (string, error) {
|
||||
cookie, err := r.Cookie(name)
|
||||
if err != nil {
|
||||
if errors.Is(err, http.ErrNoCookie) {
|
||||
return "", nil
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
return cookie.Value, nil
|
||||
}
|
||||
|
||||
func setCookie(w http.ResponseWriter, name, value string, expired time.Time) {
|
||||
cookie := http.Cookie{}
|
||||
cookie.Name = name
|
||||
cookie.Value = value
|
||||
cookie.Expires = expired
|
||||
cookie.Path = "/"
|
||||
cookie.MaxAge = int(time.Until(expired).Seconds())
|
||||
cookie.Secure = true
|
||||
cookie.HttpOnly = true
|
||||
cookie.SameSite = http.SameSiteStrictMode
|
||||
|
||||
http.SetCookie(w, &cookie)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue