Skip to content

Commit 91e595c

Browse files
Merge pull request #306 from supertokens/refactor/additional-tests-and-changes
fix: properly ignoring anti-csrf in optional session validation
2 parents cc0e0cf + e5a6ced commit 91e595c

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [unreleased]
99

10+
## [0.12.8] - 2023-07-10
11+
1012
- Adds additional tests for session verification
1113

14+
### Fixes
15+
16+
- Now properly ignoring missing anti-csrf tokens in optional session validation
17+
1218
## [0.12.7] - 2023-06-05
1319

1420
### Fixes

recipe/session/sessionRequestFunctions.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,12 @@ func GetSessionFromRequest(req *http.Request, res http.ResponseWriter, config se
179179
doAntiCsrfCheck = &doAntiCsrfCheckBool
180180
}
181181

182+
False := false
182183
if requestTokenTransferMethod != nil && *requestTokenTransferMethod == sessmodels.HeaderTransferMethod {
183-
False := false
184+
doAntiCsrfCheck = &False
185+
}
186+
187+
if accessToken == nil {
184188
doAntiCsrfCheck = &False
185189
}
186190

recipe/session/verifySession_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ func TestThatAntiCSRFCheckIsSkippedIfSessionRequiredIsFalseAndNoAccessTokenIsPas
968968
res, err := http.DefaultClient.Do(req)
969969
assert.Equal(t, res.StatusCode, 401)
970970

971-
req, err = http.NewRequest(http.MethodGet, app.URL+"/verify-optional", nil)
971+
req, err = http.NewRequest(http.MethodPost, app.URL+"/verify-optional", nil)
972972
assert.NoError(t, err)
973973

974974
res, err = http.DefaultClient.Do(req)

supertokens/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const (
2121
)
2222

2323
// VERSION current version of the lib
24-
const VERSION = "0.12.7"
24+
const VERSION = "0.12.8"
2525

2626
var (
2727
cdiSupported = []string{"2.21"}

0 commit comments

Comments
 (0)