Fix cookie weirdness (delete correctly using MaxAge)
This commit is contained in:
parent
18e07e322f
commit
9b3743e79a
2 changed files with 7 additions and 4 deletions
|
@ -156,6 +156,7 @@ func (a *Auth) routeRefresh(w http.ResponseWriter, r *http.Request) {
|
||||||
cookie := &http.Cookie{
|
cookie := &http.Cookie{
|
||||||
Name: "jwt",
|
Name: "jwt",
|
||||||
Value: tok,
|
Value: tok,
|
||||||
|
Path: "/",
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
Secure: true,
|
Secure: true,
|
||||||
}
|
}
|
||||||
|
@ -216,6 +217,7 @@ func (a *Auth) routeAuth(w http.ResponseWriter, r *http.Request) {
|
||||||
cookie := &http.Cookie{
|
cookie := &http.Cookie{
|
||||||
Name: "jwt",
|
Name: "jwt",
|
||||||
Value: tok,
|
Value: tok,
|
||||||
|
Path: "/",
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
Secure: true,
|
Secure: true,
|
||||||
}
|
}
|
||||||
|
@ -242,9 +244,10 @@ func (a *Auth) routeLogout(w http.ResponseWriter, r *http.Request) {
|
||||||
cookie := &http.Cookie{
|
cookie := &http.Cookie{
|
||||||
Name: "jwt",
|
Name: "jwt",
|
||||||
Value: "",
|
Value: "",
|
||||||
|
Path: "/",
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
Secure: true,
|
Secure: true,
|
||||||
Expires: time.Time{},
|
MaxAge: -1,
|
||||||
}
|
}
|
||||||
|
|
||||||
if a.allowInsecureCookie(r) {
|
if a.allowInsecureCookie(r) {
|
||||||
|
|
|
@ -43,11 +43,11 @@ var ErrBadTG = errors.New("bad talkgroup format")
|
||||||
func (tid *ID) UnmarshalJSON(j []byte) error {
|
func (tid *ID) UnmarshalJSON(j []byte) error {
|
||||||
// this is a dirty hack since we cannot implement both TextUnmarshaler
|
// this is a dirty hack since we cannot implement both TextUnmarshaler
|
||||||
// and json.Unmarshaler at the same time. sigh.
|
// and json.Unmarshaler at the same time. sigh.
|
||||||
v := &struct{
|
v := &struct {
|
||||||
System uint32 `json:"sys"`
|
System uint32 `json:"sys"`
|
||||||
Talkgroup uint32 `json:"tg"`
|
Talkgroup uint32 `json:"tg"`
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
if tid != nil {
|
if tid != nil {
|
||||||
v.System, v.Talkgroup = tid.System, tid.Talkgroup
|
v.System, v.Talkgroup = tid.System, tid.Talkgroup
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue