authorization
Module[Authorization]: the roles of the current request and whether a
permission list grants an action to them.
Contents
use utopia_database::Authorization;Rust
pub struct AuthorizationThe current roles, and whether authorization is enforced.
Rust
use utopia_database::validator::authorization::{Authorization, Input};
let auth = Authorization::new();
auth.add_role("user:1");
assert!(auth.is_valid(&Input::new("read", vec!["user:1".into()])));
assert!(!auth.is_valid(&Input::new("read", vec!["user:2".into()])));
assert_eq!(auth.description(), "Missing \"read\" permission for role \"user:2\". Only \"[\"any\",\"user:1\"]\" scopes are allowed and \"[\"user:2\"]\" was given.");Also implements
Default, Validator.use utopia_database::validator::authorization::Input;Rust
pub struct InputThe action and permissions an Authorization checks.