Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secure cookie fix #160

Merged
merged 5 commits into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ fun Routing.createSongRoutes() {
songId = songId,
)
streamData.cookies.forEach { cookie ->
response.cookies.append(name = cookie.key, value = cookie.value, domain = "newm.io")
response.cookies.append(
name = cookie.key,
value = cookie.value,
domain = "newm.io",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

domain can be referenced from application.conf with a default value of "newm.io".

path = "/",
extensions = mapOf("SameSite" to "Strict")
)
}
respond(
AudioStreamResponse(streamData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import kotlinx.serialization.Serializable

@Serializable
data class AudioStreamResponse(
val url: String,
val cookies: Map<String, String>
val url: String
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed cookie argument because it is not required in the response (cookies are passed in the header)

) {
constructor(data: AudioStreamData) : this(data.url, data.cookies)
constructor(data: AudioStreamData) : this(data.url)
}

interface AudioStreamData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -797,11 +797,6 @@ class SongRoutesTests : BaseApplicationTests() {
val environment: ApplicationEnvironment by inject()
val updatedHost = environment.getConfigString("aws.cloudFront.audioStream.hostUrl")
assertThat(resp.url).startsWith(updatedHost)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer required

// assert that cookies are created
assertThat(resp.cookies).containsKey("CloudFront-Signature")
assertThat(resp.cookies).containsKey("CloudFront-Key-Pair-Id")
assertThat(resp.cookies).containsKey("CloudFront-Policy")
}

// TODO: complete implementation of testGenerateMintingPaymentTransaction() bellow
Expand Down