-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix(cookies): add {cookie-name}-parts
cookie, style: inline formatting
#107
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,6 @@ impl Session { | |
encoded_nonce: &str, | ||
cookie_name: &str, | ||
cookie_duration: u64, | ||
number_current_cookies: u64, | ||
) -> Vec<String> { | ||
// Split every 4000 bytes | ||
let cookie_parts = encoded_cookie | ||
|
@@ -109,22 +108,17 @@ impl Session { | |
cookie_values.push(cookie_value); | ||
} | ||
|
||
let num_parts = cookie_values.len(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a comment which explains what you are doing here :) |
||
let num_parts_cookie_value = format!("{cookie_name}-parts={num_parts}; Path=/; HttpOnly; Secure; Max-Age={cookie_duration}; "); | ||
cookie_values.push(num_parts_cookie_value); | ||
|
||
// Build nonce cookie value | ||
let nonce_cookie_value = format!( | ||
"{}-nonce={}; Path=/; HttpOnly; Secure; Max-Age={}; ", | ||
cookie_name, &encoded_nonce, cookie_duration | ||
); | ||
cookie_values.push(nonce_cookie_value); | ||
|
||
// Overwrite the old cookies because decryption will fail if older and expired cookies are | ||
// still present. | ||
for i in cookie_values.len()..number_current_cookies as usize { | ||
cookie_values.push(format!( | ||
"{}-{}=; Path=/; HttpOnly; Secure; Max-Age=0", | ||
cookie_name, i | ||
)); | ||
} | ||
|
||
cookie_values | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically its not the Session Cookie right? We should add another Error for this type as Nonce also has its own error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is worth the effort. I would consider all of the cookies together "the session cookie" because it doesn't really make a difference to the user which is missing, the end result is the same. In fact, I would like to refactor the error handling completely to use
anyhow
instead of defining a custom error type withthiserror
. Initially I thought we mightmatch
on the error variant somewhere and do different things depending on the error, but we don't actually do that. Furthermore,PluginError
is just a catch-all error type anyway, that doesn't reflect which errors a function can actually throw.fn validate_cookie(&self) -> Result<AuthorizationState, PluginError>
will never returnErr(PluginError::CodeNotFoundInCallbackError)
, but the return type makes it look like it could.