pub enum SpiceDbObject {
Server(String),
Channel(String),
User(String),
PermissionOverride(String),
}Expand description
Represents different types of objects in the SpiceDB authorization system.
SpiceDbObject is used to identify resources and subjects when performing
permission checks. Each variant represents a different type of entity in your
application’s domain model.
§Object Types
- Server - A server/workspace that contains channels, users, and roles
- Channel - A communication channel within a server
- User - A user/subject that can have permissions
- PermissionOverride - A permission override rule
§Examples
use authz::{SpiceDbObject, SpiceDbRepository, Permissions};
// Check if a user can view a channel
let result = repo.check_permissions(
SpiceDbObject::Channel("general-chat".to_string()),
Permissions::ViewChannels,
SpiceDbObject::User("user-123".to_string()),
).await;
// Check if a user is a server admin
let is_admin = repo.check_permissions(
SpiceDbObject::Server("my-server".to_string()),
Permissions::Administrator,
SpiceDbObject::User("user-456".to_string()),
).await.has_permissions();§SpiceDB Integration
Each SpiceDbObject is converted into a SpiceDB ObjectReference when
communicating with the SpiceDB API. The object type determines the namespace
used in SpiceDB’s schema.
Variants§
Server(String)
A server object identified by its unique ID.
Servers are top-level containers that can have channels, users, roles, and other resources. They correspond to the “server” object type in SpiceDB.
§Example
use authz::SpiceDbObject;
let server = SpiceDbObject::Server("server-abc-123".to_string());Channel(String)
A channel object identified by its unique ID.
Channels are communication spaces within a server where users can view and send messages. They correspond to the “channel” object type in SpiceDB.
§Example
use authz::SpiceDbObject;
let channel = SpiceDbObject::Channel("channel-xyz-789".to_string());User(String)
A user object identified by its unique ID.
Users are subjects that can have permissions on resources. They correspond to the “user” object type in SpiceDB.
§Example
use authz::SpiceDbObject;
let user = SpiceDbObject::User("user-def-456".to_string());PermissionOverride(String)
A permission override object identified by its unique ID.
Permission overrides allow fine-grained control over access rules. They correspond to the “permission_override” object type in SpiceDB.
§Example
use authz::SpiceDbObject;
let override_rule = SpiceDbObject::PermissionOverride("override-001".to_string());Trait Implementations§
Source§impl Into<ObjectReference> for SpiceDbObject
Converts a SpiceDbObject into a SpiceDB ObjectReference.
impl Into<ObjectReference> for SpiceDbObject
Converts a SpiceDbObject into a SpiceDB ObjectReference.
This implementation allows SpiceDbObject to be used directly in permission
check operations. The conversion maps the object to SpiceDB’s wire format.
Source§fn into(self) -> ObjectReference
fn into(self) -> ObjectReference
Auto Trait Implementations§
impl Freeze for SpiceDbObject
impl RefUnwindSafe for SpiceDbObject
impl Send for SpiceDbObject
impl Sync for SpiceDbObject
impl Unpin for SpiceDbObject
impl UnwindSafe for SpiceDbObject
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request