Skip to main content

surrealdb_sql/
access.rs

1use crate::{Expr, Literal};
2
3#[derive(Debug, Clone, Eq, PartialEq)]
4#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
5// Durations representing the expiration of different elements of the access
6// method In this context, the None variant represents that the element does not
7// expire
8pub struct AccessDuration {
9	// Duration after which the grants generated with the access method expire
10	// For access methods whose grants are tokens, this value is irrelevant
11	pub grant: Expr,
12	// Duration after which the tokens obtained with the access method expire
13	// For access methods that cannot issue tokens, this value is irrelevant
14	pub token: Expr,
15	// Duration after which the session authenticated with the access method expires
16	pub session: Expr,
17}
18
19impl Default for AccessDuration {
20	fn default() -> Self {
21		Self {
22			// By default, access grants expire in 30 days.
23			grant: Expr::Literal(Literal::Duration(std::time::Duration::from_secs(30 * 86400))),
24			// By default, tokens expire after one hour
25			token: Expr::Literal(Literal::Duration(std::time::Duration::from_secs(3600))),
26			// By default, sessions do not expire
27			session: Expr::Literal(Literal::None),
28		}
29	}
30}