Skip to content

Commit

Permalink
fix: explain mitigations in cookie error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Jan 5, 2022
1 parent 469a5ed commit ef4b01a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion continuity/manager_cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

var _ Manager = new(ManagerCookie)
var ErrNotResumable = *herodot.ErrBadRequest.WithError("session is not resumable").WithReasonf("No resumable session could be found in the HTTP Header.")
var ErrNotResumable = *herodot.ErrBadRequest.WithError("no resumable session found").WithReasonf("The browser does not contain the neccesary cookie to resume the session. This is a security violation and was thus blocked. Please clear your browser's cookies and cache and try again!")

const cookieName = "ory_kratos_continuity"

Expand Down
6 changes: 3 additions & 3 deletions continuity/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestManager(t *testing.T) {

body := ioutilx.MustReadAll(res.Body)
require.Equal(t, http.StatusBadRequest, res.StatusCode)
assert.Contains(t, gjson.GetBytes(body, "error.reason").String(), "resumable session")
assert.Contains(t, gjson.GetBytes(body, "error.reason").String(), continuity.ErrNotResumable.ReasonField)
})

t.Run("case=pause and resume session", func(t *testing.T) {
Expand Down Expand Up @@ -174,7 +174,7 @@ func TestManager(t *testing.T) {
require.Equal(t, http.StatusBadRequest, res.StatusCode)
body := ioutilx.MustReadAll(res.Body)
t.Cleanup(func() { require.NoError(t, res.Body.Close()) })
assert.Contains(t, gjson.GetBytes(body, "error.reason").String(), "resumable session")
assert.Contains(t, gjson.GetBytes(body, "error.reason").String(), continuity.ErrNotResumable.ReasonField)
})

t.Run("case=pause and resume session in the same request", func(t *testing.T) {
Expand Down Expand Up @@ -210,7 +210,7 @@ func TestManager(t *testing.T) {

require.Equal(t, http.StatusBadRequest, res.StatusCode)
body := ioutilx.MustReadAll(res.Body)
assert.Contains(t, gjson.GetBytes(body, "error.reason").String(), "resumable session")
assert.Contains(t, gjson.GetBytes(body, "error.reason").String(), continuity.ErrNotResumable.ReasonField)
})
})
}
Expand Down
2 changes: 1 addition & 1 deletion x/nosurf.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (
WithID(text.ErrIDCSRF).
WithError("the request was rejected to protect you from Cross-Site-Request-Forgery").
WithDetail("docs", "https://www.ory.sh/kratos/docs/debug/csrf").
WithReason("The request was rejected to protect you from Cross-Site-Request-Forgery (CSRF) which could cause account takeover, leaking personal information, and other serious security issues.")
WithReason("Please retry the flow and optionally clear your cookies. The request was rejected to protect you from Cross-Site-Request-Forgery (CSRF) which could cause account takeover, leaking personal information, and other serious security issues.")
ErrGone = herodot.DefaultError{
CodeField: http.StatusGone,
StatusField: http.StatusText(http.StatusGone),
Expand Down

0 comments on commit ef4b01a

Please sign in to comment.