pub struct RailsCookieParser { /* private fields */ }
Expand description
Base object and structure
Implementations§
Source§impl RailsCookieParser
impl RailsCookieParser
Sourcepub fn default_rails5() -> Self
pub fn default_rails5() -> Self
Default builder for a Rails 5 cookie
Calls the same implementation as Self::default_rails6()
.
Sourcepub fn default_rails6() -> Self
pub fn default_rails6() -> Self
Default builder for a Rails 6 cookie
Functions just like Self::default()
, but uses the pre-Rails 7 hash of Sha1.
Sourcepub fn default_rails7() -> Self
pub fn default_rails7() -> Self
Default builder for a Rails 7 cookie
Since Rails 7 is the latest stable, the implementation is exactly the same
as Self::default()
.
Sourcepub fn new(
key_base: &str,
key_salt: &str,
iterations: u32,
key_hash: HashDigest,
) -> Self
pub fn new( key_base: &str, key_salt: &str, iterations: u32, key_hash: HashDigest, ) -> Self
Creates a new decryption object
All arguments can be customised in case you have a very specific setup for your Rails server.
Most of the time, you can use the default functions, but here, you can add all the customisation you require:
key_base
: Your RailsSECRET_KEY_BASE
string.key_salt
: Your Rails salt string. If unsure, just use"authenticated encrypted cookie"
.iterations
: Unless you know you changed it,1000
.key_hash
: Can beSha1
orSha256
depending on your Rails version.
Decipher a cookie into a JSON string
Only the decryption is done, this library will not tell you how to use the resulting JSON.
Trait Implementations§
Source§impl Default for RailsCookieParser
impl Default for RailsCookieParser
Source§fn default() -> Self
fn default() -> Self
Default implementation for RailsCookieParser
The default implementation is meant to be “plug and play” and uses Rails 7 defaults, which are:
- Key base is taken from ENV value for
SECRET_KEY_BASE
. - Key salt is Rails default
"authenticated encrypted cookie"
. - Iterations:
1000
. - Hash digest is
Sha256
since Rails 7.