Skip to content

Commit 8599fe9

Browse files
committed
[app] Delete all cookies on signout
Until now we only deleted the main cookie when the user clicks the signout button. This is now changed so that all cookies are deleted. This means that also the cookies generated by plugins are deleted when they are starting with "kobs".
1 parent 3a1e4ed commit 8599fe9

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ NOTE: As semantic versioning states all 0.y.z releases can contain breaking chan
4949
- [#417](https://github.com/kobsio/kobs/pull/417): [jira] Adjust notification style based on the issue status.
5050
- [#418](https://github.com/kobsio/kobs/pull/418): [app] Go to details page when a user selects an application.
5151
- [#420](https://github.com/kobsio/kobs/pull/420): [app] Use generics for `jwt` package and reuse the package for the GitHub and Jira plugin, to make the generated cookies more secure.
52+
- [#421](https://github.com/kobsio/kobs/pull/421): [app] Delete all cookies on signout.
5253

5354
## [v0.9.1](https://github.com/kobsio/kobs/releases/tag/v0.9.1) (2022-07-08)
5455

pkg/hub/auth/auth.go

+14-8
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,20 @@ func (c *client) signinHandler(w http.ResponseWriter, r *http.Request) {
209209
// signoutHandler handles the logout for an user. For this we are setting the value of the auth cookie to an empty
210210
// string and we adjust the expiration date of the cookie.
211211
func (c *client) signoutHandler(w http.ResponseWriter, r *http.Request) {
212-
http.SetCookie(w, &http.Cookie{
213-
Name: "kobs",
214-
Value: "",
215-
Path: "/",
216-
Secure: true,
217-
HttpOnly: true,
218-
Expires: time.Unix(0, 0),
219-
})
212+
cookies := r.Cookies()
213+
214+
for _, cookie := range cookies {
215+
if strings.HasPrefix(cookie.Name, "kobs") {
216+
http.SetCookie(w, &http.Cookie{
217+
Name: cookie.Name,
218+
Value: "",
219+
Path: "/",
220+
Secure: true,
221+
HttpOnly: true,
222+
Expires: time.Unix(0, 0),
223+
})
224+
}
225+
}
220226

221227
render.JSON(w, r, nil)
222228
}

0 commit comments

Comments
 (0)