You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// The number of seconds until the session cookie expires. Specify a duration in seconds, between five minutes and fourteen days, inclusively.
315
+
#[serde(rename = "validDuration")]
316
+
valid_duration:u64,
317
+
#[serde(rename = "tenantId")]
318
+
#[serde(skip_serializing_if = "Option::is_none")]
319
+
tenant_id:Option<String>,
320
+
}
321
+
322
+
#[derive(Debug,Deserialize)]
323
+
structOauth2ResponseDTO{
324
+
access_token:String,
325
+
expires_in:u64,
326
+
token_type:String,
327
+
}
328
+
329
+
/// Firebase Auth provides server-side session cookie management for traditional websites that rely on session cookies.
330
+
/// This solution has several advantages over client-side short-lived ID tokens,
331
+
/// which may require a redirect mechanism each time to update the session cookie on expiration:
332
+
///
333
+
/// * Improved security via JWT-based session tokens that can only be generated using authorized service accounts.
334
+
/// * Stateless session cookies that come with all the benefit of using JWTs for authentication.
335
+
/// The session cookie has the same claims (including custom claims) as the ID token, making the same permissions checks enforceable on the session cookies.
336
+
/// * Ability to create session cookies with custom expiration times ranging from 5 minutes to 2 weeks.
337
+
/// * Flexibility to enforce cookie policies based on application requirements: domain, path, secure, httpOnly, etc.
338
+
/// * Ability to revoke session cookies when token theft is suspected using the existing refresh token revocation API.
339
+
/// * Ability to detect session revocation on major account changes.
340
+
///
341
+
/// See https://firebase.google.com/docs/auth/admin/manage-cookies
342
+
///
343
+
/// The generated session cookie is a JWT that includes the firebase user id in the "sub" (subject) field.
344
+
///
345
+
/// Arguments:
346
+
/// - `credentials` The credentials
347
+
/// - `id_token` An access token, sometimes called a firebase id token.
348
+
/// - `duration` The cookie duration
349
+
///
350
+
pubfncreate(
351
+
credentials:&credentials::Credentials,
352
+
id_token:String,
353
+
duration: chrono::Duration,
354
+
) -> Result<String,FirebaseError>{
355
+
// Generate the assertion from the admin credentials
356
+
let assertion = crate::jwt::session_cookie::create_jwt_encoded(credentials, duration)?;
357
+
358
+
// Request Google Oauth2 to retrieve the access token in order to create a session cookie
0 commit comments