Skip to content

Commit b827deb

Browse files
Merge pull request #407 from furkansenharputlu/fix/session-required-signout
fix: session required in signout
2 parents 2d5fac1 + 15a6ce7 commit b827deb

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

CHANGELOG.md

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

1010
- `session.CreateNewSession` now defaults to the value of the `st-auth-mode` header (if available) if the configured `config.GetTokenTransferMethod` returns `any`.
1111
- Enable smooth switching between `useDynamicAccessTokenSigningKey` settings by allowing refresh calls to change the signing key type of a session.
12+
- Make session required during signout.
1213

1314
## [0.17.5] - 2024-03-14
1415
- Adds a type uint64 to the `accessTokenCookiesExpiryDurationMillis` local variable in `recipe/session/utils.go`. It also removes the redundant `uint64` type forcing needed because of the untyped variable.

recipe/emailpassword/authFlow_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ func TestDefaultSignoutRouteRevokesSession(t *testing.T) {
13871387
assert.Equal(t, "", cookieData1["refreshTokenDomain"])
13881388
}
13891389

1390-
func TestCallingTheAPIwithoutSessionShouldReturnOk(t *testing.T) {
1390+
func TestCallingTheAPIwithoutSessionShouldReturnUnauthorized(t *testing.T) {
13911391
configValue := supertokens.TypeInput{
13921392
Supertokens: &supertokens.ConnectionInfo{
13931393
ConnectionURI: "http://localhost:8080",
@@ -1442,8 +1442,8 @@ func TestCallingTheAPIwithoutSessionShouldReturnOk(t *testing.T) {
14421442
t.Error(err.Error())
14431443
}
14441444

1445-
assert.Equal(t, 200, res.StatusCode)
1446-
assert.Equal(t, "OK", data["status"])
1445+
assert.Equal(t, http.StatusUnauthorized, res.StatusCode)
1446+
assert.Empty(t, data["status"])
14471447
assert.Nil(t, req.Header["Cookie"])
14481448
}
14491449

recipe/session/signout.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ func SignOutAPI(apiImplementation sessmodels.APIInterface, options sessmodels.AP
2727
return nil
2828
}
2929

30-
False := false
30+
sessionRequired := true
3131
sessionContainer, err := GetSessionFromRequest(options.Req, options.Res, options.Config, &sessmodels.VerifySessionOptions{
32-
SessionRequired: &False,
32+
SessionRequired: &sessionRequired,
3333
OverrideGlobalClaimValidators: func(globalClaimValidators []claims.SessionClaimValidator, sessionContainer sessmodels.SessionContainer, userContext supertokens.UserContext) ([]claims.SessionClaimValidator, error) {
3434
return []claims.SessionClaimValidator{}, nil
3535
},

recipe/thirdparty/signoutFeature_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
"gopkg.in/h2non/gock.v1"
3636
)
3737

38-
func TestThatCallingTheAPIwithoutASessionShouldReturnOk(t *testing.T) {
38+
func TestThatCallingTheAPIwithoutASessionShouldReturnUnauthorized(t *testing.T) {
3939
configValue := supertokens.TypeInput{
4040
Supertokens: &supertokens.ConnectionInfo{
4141
ConnectionURI: "http://localhost:8080",
@@ -80,7 +80,7 @@ func TestThatCallingTheAPIwithoutASessionShouldReturnOk(t *testing.T) {
8080
if err != nil {
8181
t.Error(err.Error())
8282
}
83-
assert.Equal(t, http.StatusOK, resp.StatusCode)
83+
assert.Equal(t, http.StatusUnauthorized, resp.StatusCode)
8484

8585
dataInBytes, err := ioutil.ReadAll(resp.Body)
8686
if err != nil {
@@ -94,7 +94,7 @@ func TestThatCallingTheAPIwithoutASessionShouldReturnOk(t *testing.T) {
9494
t.Error(err.Error())
9595
}
9696

97-
assert.Equal(t, "OK", response["status"])
97+
assert.Empty(t, response["status"])
9898

9999
assert.Equal(t, 0, len(resp.Cookies()))
100100
}

0 commit comments

Comments
 (0)