cf-modkit-db-macros 0.1.0

Proc-macro derives for modkit-db secure ORM layer
Documentation

modkit-db-macros

Procedural macros for the modkit-db secure ORM layer.

#[derive(Scopable)]

Automatically implements ScopableEntity for a SeaORM entity based on attributes.

IMPORTANT: All four scope dimensions must be explicitly specified. No implicit defaults.

Example

use sea_orm::entity::prelude::*;
use modkit_db::secure::Scopable;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Scopable)]
#[sea_orm(table_name = "users")]
#[secure(
    tenant_col = "tenant_id",
    resource_col = "id",
    no_owner,
    no_type
)]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: Uuid,
    pub tenant_id: Uuid,
    pub email: String,
}

Attributes

Each scope dimension requires exactly one declaration:

  • Tenant: tenant_col = "column_name" OR no_tenant
  • Resource: resource_col = "column_name" OR no_resource
  • Owner: owner_col = "column_name" OR no_owner
  • Type: type_col = "column_name" OR no_type
  • Unrestricted: unrestricted (forbids all other attributes)

Note on OData Macros

OData-related derives like ODataFilterable have been moved to modkit-odata-macros. Use that crate for OData protocol macros.