-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change cookie path and no redirect on expired session
- Loading branch information
Showing
58 changed files
with
338 additions
and
163 deletions.
There are no files selected for viewing
26 changes: 21 additions & 5 deletions
26
repository/Seaside-Core.package/WARegistry.class/instance/handleExpired..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,23 @@ | ||
handling | ||
handleExpired: aRequestContext | ||
"This method is called whenever a request is received with a key that does not match a registered handler." | ||
|
||
aRequestContext responseGenerator | ||
expiredRegistryKey; | ||
respond | ||
"This method is called whenever a request is received with a key that does not match a registered handler." | ||
|
||
aRequestContext request isXmlHttpRequest ifTrue: [ | ||
^ aRequestContext responseGenerator | ||
forbidden; | ||
respond ]. | ||
|
||
"Previously, Seaside used to send a redirect response (302) with the | ||
'Location' header set to the same path as in the request (if possible). | ||
Any session cookie would at this point have been set for deletion (i.e. | ||
a 'Set-Cookie' header with a request for deletion would have been set). | ||
Unfortunately, user-agents across the board don't play well with 'Set-Cookie' | ||
and redirect responses. | ||
Hence, we proceed and respond as usual. If a session is to be created, | ||
another 'Set-Cookie' header will tell the browser to use the new | ||
session identifier from now on. | ||
Nice side-effect: user-agents will no longer need to perform the additional | ||
redirect when a stale cookie is still in the cache. | ||
See https://github.com/SeasideSt/Seaside/issues/916." | ||
self handleDefault: aRequestContext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
repository/Seaside-Core.package/WARequestCookie.class/instance/initialize.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
initialization | ||
initialize | ||
super initialize. | ||
|
||
"According to https://tools.ietf.org/html/rfc6265#section-5.1.4 | ||
user-agents must use '/' as the default path (see class comment)" | ||
path := '/'. | ||
pathEncoded := '/' |
6 changes: 5 additions & 1 deletion
6
repository/Seaside-Core.package/WARequestCookie.class/instance/path..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
accessing | ||
path: aString | ||
self pathUnencoded: aString codec: nil | ||
path := self sanitizePath: aString. | ||
|
||
self | ||
pathUnencoded: path | ||
codec: nil |
2 changes: 1 addition & 1 deletion
2
repository/Seaside-Core.package/WARequestCookie.class/instance/path.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
accessing | ||
path | ||
^ path ifNil: [ '/' ] | ||
^ path |
21 changes: 10 additions & 11 deletions
21
repository/Seaside-Core.package/WARequestCookie.class/instance/pathUnencoded.codec..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
accessing | ||
pathUnencoded: aString codec: aCodec | ||
path := aString. | ||
pathEncoded := aString isNil | ||
ifTrue: [ '/' ] | ||
ifFalse: [ | ||
| codec | | ||
aString = '/' ifTrue: [ | ||
pathEncoded := '/'. | ||
^ self ]. | ||
|
||
pathEncoded := String new: (aString size * 1.1) greaseInteger streamContents: [ :stream | | ||
| codec encoder | | ||
codec := aCodec isNil ifTrue: [ self requestContext codec ] ifFalse: [ aCodec ]. | ||
String new: (aString size * 1.1) greaseInteger streamContents: [ :stream | | ||
| encoder | | ||
encoder := GRPlatform current urlEncoderOn: stream codec: codec. | ||
GRPlatform subStringsIn: path splitBy: $/ do: [ :each | | ||
stream nextPut: $/. | ||
encoder nextPutAll: each ] ] ] | ||
encoder := GRPlatform current urlEncoderOn: stream codec: codec. | ||
GRPlatform subStringsIn: aString splitBy: $/ do: [ :each | | ||
stream nextPut: $/. | ||
encoder nextPutAll: each ] ] |
4 changes: 2 additions & 2 deletions
4
repository/Seaside-Core.package/WARequestCookie.class/instance/pathUnencoded.encoded..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
accessing | ||
pathUnencoded: aFirstString encoded: aSecondString | ||
path := aFirstString. | ||
pathEncoded := aSecondString | ||
path := self sanitizePath: aFirstString. | ||
pathEncoded := self sanitizePath: aSecondString |
2 changes: 1 addition & 1 deletion
2
repository/Seaside-Core.package/WARequestCookie.class/instance/pathUnencoded.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
accessing | ||
pathUnencoded | ||
^ path | ||
^ self path |
15 changes: 15 additions & 0 deletions
15
repository/Seaside-Core.package/WARequestCookie.class/instance/sanitizePath..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
private | ||
sanitizePath: aString | ||
"Make sure aString follows https://tools.ietf.org/html/rfc6265#section-5.1.4 rules" | ||
| sanitized | | ||
sanitized := aString. | ||
(#(nil '' '/') includes: sanitized) ifTrue: [ | ||
"treat nil '' '/' all as '/" | ||
sanitized := '/' ]. | ||
"make sure path starts with /" | ||
sanitized first = $/ ifFalse: [ | ||
sanitized := '/', sanitized ]. | ||
"make sure path does not end with /" | ||
[ sanitized size > 1 and: [ sanitized last = $/ ] ] whileTrue: [ | ||
sanitized := sanitized allButLast ]. | ||
^ sanitized |
12 changes: 7 additions & 5 deletions
12
repository/Seaside-Core.package/WARequestCookie.class/methodProperties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
repository/Seaside-Core.package/WARequestCookie.class/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
repository/Seaside-Tests-Core.package/WACookieTest.class/instance/testSettingEmptyPath.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
tests | ||
testSettingEmptyPath | ||
"According to https://tools.ietf.org/html/rfc6265#section-5.1.4 | ||
user-agents must use '/' as the default path (see class comment)" | ||
| cookie | | ||
cookie := WACookie new | ||
key: 'name'; | ||
value: 'homer'; | ||
path: ''; | ||
yourself. | ||
|
||
self assert: cookie path equals: '/'. | ||
self assert: cookie pathUnencoded equals: '/'. | ||
self assert: cookie pathEncoded equals: '/' |
14 changes: 14 additions & 0 deletions
14
repository/Seaside-Tests-Core.package/WACookieTest.class/instance/testSettingNilPath.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
tests | ||
testSettingNilPath | ||
"According to https://tools.ietf.org/html/rfc6265#section-5.1.4 | ||
user-agents must use '/' as the default path (see class comment)" | ||
| cookie | | ||
cookie := WACookie new | ||
key: 'name'; | ||
value: 'homer'; | ||
path: nil; | ||
yourself. | ||
|
||
self assert: cookie path equals: '/'. | ||
self assert: cookie pathUnencoded equals: '/'. | ||
self assert: cookie pathEncoded equals: '/' |
14 changes: 14 additions & 0 deletions
14
...easide-Tests-Core.package/WACookieTest.class/instance/testSettingPathWithTrailingSlash.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
tests | ||
testSettingPathWithTrailingSlash | ||
"According to https://tools.ietf.org/html/rfc6265#section-5.1.4 | ||
trailing slashes must be ignored by user-agents (see class comment)" | ||
| cookie | | ||
cookie := WACookie new | ||
key: 'name'; | ||
value: 'homer'; | ||
path: '/springfield/'; | ||
yourself. | ||
|
||
self assert: cookie path equals: '/springfield'. | ||
self assert: cookie pathUnencoded equals: '/springfield'. | ||
self assert: cookie pathEncoded equals: '/springfield' |
15 changes: 15 additions & 0 deletions
15
...side-Tests-Core.package/WACookieTest.class/instance/testSettingPathWithoutLeadingSlash.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
tests | ||
testSettingPathWithoutLeadingSlash | ||
"According to https://tools.ietf.org/html/rfc6265#section-5.1.4 | ||
user-agents must ignore paths without leading slash and use '/'. | ||
We ensure that the path starts with slash. (see class comment)" | ||
| cookie | | ||
cookie := WACookie new | ||
key: 'name'; | ||
value: 'homer'; | ||
path: 'springfield/powerplant'; | ||
yourself. | ||
|
||
self assert: cookie path equals: '/springfield/powerplant'. | ||
self assert: cookie pathUnencoded equals: '/springfield/powerplant'. | ||
self assert: cookie pathEncoded equals: '/springfield/powerplant' |
12 changes: 12 additions & 0 deletions
12
repository/Seaside-Tests-Core.package/WACookieTest.class/instance/testSettingRegularPath.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
tests | ||
testSettingRegularPath | ||
| cookie | | ||
cookie := WACookie new | ||
key: 'name'; | ||
value: 'homer'; | ||
path: '/springfield/powerplant'; | ||
yourself. | ||
|
||
self assert: cookie path equals: '/springfield/powerplant'. | ||
self assert: cookie pathUnencoded equals: '/springfield/powerplant'. | ||
self assert: cookie pathEncoded equals: '/springfield/powerplant' |
12 changes: 12 additions & 0 deletions
12
repository/Seaside-Tests-Core.package/WACookieTest.class/instance/testSettingRootPath.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
tests | ||
testSettingRootPath | ||
| cookie | | ||
cookie := WACookie new | ||
key: 'name'; | ||
value: 'homer'; | ||
path: '/'; | ||
yourself. | ||
|
||
self assert: cookie path equals: '/'. | ||
self assert: cookie pathUnencoded equals: '/'. | ||
self assert: cookie pathEncoded equals: '/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 11 additions & 5 deletions
16
repository/Seaside-Tests-Core.package/WACookieTest.class/methodProperties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
{ | ||
"instance" : { | ||
"testCopy" : "pmm 9/1/2012 16:17", | ||
"testWriteOn" : "pmm 8/16/2014 14:19", | ||
"testFromStringRfc2965" : "pmm 9/11/2013 12:24", | ||
"testExpireInPast" : "pmm 4/5/2008 15:42", | ||
"testExpirePrinting" : "pmm 8/16/2014 13:40", | ||
"testWriteOn" : "pmm 9/10/2018 15:10", | ||
"testFromStringOldNetscape" : "pmm 9/11/2013 12:22", | ||
"testSettingRootPath" : "pmm 9/10/2018 15:10", | ||
"testPathEncoding" : "pmm 9/11/2013 12:42", | ||
"testExpirePrinting" : "pmm 9/10/2018 15:08", | ||
"testSettingNilPath" : "pmm 9/10/2018 15:09", | ||
"testSettingPathWithoutLeadingSlash" : "pmm 9/10/2018 15:10", | ||
"testEquals" : "pmm 9/1/2012 16:17", | ||
"testCombine" : "pmm 8/16/2014 14:01" | ||
"testExpireInPast" : "pmm 4/5/2008 15:42", | ||
"testSettingEmptyPath" : "pmm 9/10/2018 15:09", | ||
"testSettingPathWithTrailingSlash" : "pmm 9/10/2018 15:09", | ||
"testFromStringRfc2965" : "pmm 9/11/2013 12:24", | ||
"testSettingRegularPath" : "pmm 9/10/2018 15:10", | ||
"testCombine" : "pmm 9/10/2018 15:07" | ||
}, | ||
"class" : { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.