pub struct Session {
pub issuer: String,
pub authorization_state: Option<AuthorizationState>,
pub original_path: String,
pub code_verifier: String,
pub state: String,
}Expand description
Struct that holds all information about the current session including the authorization state, the original path, the PKCE code verifier and the state
Fields§
§issuer: StringIssuer of the OpenID Connect Provider
Authorization state
original_path: StringOriginal Path to which the user should be redirected after login
code_verifier: StringPKCE Code Verifier used to generate the PKCE Code Challenge
state: StringState used to prevent CSRF attacks
Implementations§
Source§impl Session
impl Session
Sourcepub fn encrypt_and_encode(
&self,
cipher: Aes256Gcm,
) -> Result<(String, String), PluginError>
pub fn encrypt_and_encode( &self, cipher: Aes256Gcm, ) -> Result<(String, String), PluginError>
Create a new session, encrypt it and encode it by using the given cipher
cipher- Cipher used to encrypt the cookie
Returns:
- the base64 encoded encrypted session data
- the base64 encoded nonce needed to decrypt it
Make the cookie values from the encoded cookie by splitting it into chunks of 4000 bytes and then building the values to be set in the Set-Cookie headers
encoded_cookie- Encoded cookie to be split into chunks of 4000 bytesencoded_nonce- Base64 encoded nonce needed to decrypt the cookiecookie_name- Name of the cookiecookie_duration_in_s- Duration of the cookie in seconds
Build Set-Cookie values that expire all session cookie parts immediately.
num_parts should be the current {cookie_name}-parts value from the request
(default to at least 1 so {cookie_name}-0 is cleared even if -parts is missing).
Make the Set-Cookie headers from the cookie values
cookie_values- Cookie values to be set in the Set-Cookie headers
Sourcepub fn decode_and_decrypt(
encoded_cookie: String,
cipher: Aes256Gcm,
encoded_nonce: String,
) -> Result<Session, PluginError>
pub fn decode_and_decrypt( encoded_cookie: String, cipher: Aes256Gcm, encoded_nonce: String, ) -> Result<Session, PluginError>
Decode cookie, parse into a struct in order to access the fields
encoded_cookie- Encoded cookie to be decoded and parsed into a structcipher- Cipher used to decrypt the cookieencoded_nonce- Nonce used to decrypt the cookie