Skip to main content

Subject

Enum Subject 

Source
pub enum Subject<'a> {
    Write {
        account: &'a str,
        attributes: SubjectAttributes<'a>,
        universal: Universal<'a>,
        client_id: Option<&'a ClientId>,
        collection: &'a str,
        action: WriteAction,
        diff: Diff<'a>,
        before: Option<&'a Value>,
        after: Option<&'a Value>,
        lookups: &'a [Lookup<'a>],
    },
    Blob {
        account: &'a str,
        attributes: SubjectAttributes<'a>,
        universal: Universal<'a>,
        client_id: Option<&'a ClientId>,
        mime_type: &'a str,
        sniffed: Option<&'a str>,
        size: Option<u64>,
    },
    Grant {
        universal: Universal<'a>,
        client_id: &'a ClientId,
        requested_scopes: &'a [&'a str],
    },
    Token {
        account: &'a str,
        attributes: SubjectAttributes<'a>,
        universal: Universal<'a>,
        client_id: &'a ClientId,
        scopes: &'a [&'a str],
    },
    Create {
        account: &'a str,
        attributes: Option<SubjectAttributes<'a>>,
        universal: Universal<'a>,
        kind: SubjectKind<'a>,
        asked: Asked,
        pool: &'a str,
        zone: &'a str,
        name: Option<&'a str>,
        label: Option<&'a str>,
    },
}
Expand description

What one policy is asked to decide about.

A client appears on all three variants, so a rule denying a client answers the same way at sign-in, at token issue, and at the write. The write matters most: a token issued before a denial still reaches it.

Variants§

§

Write

A write to this account’s own repository. Typically an agent’s, but see AccountKind — the field is named for what it is, an account DID, not for the kind that happens to be the common case.

Fields

§account: &'a str

The account whose repository this is.

§attributes: SubjectAttributes<'a>

Other attributes of that account a policy may reference — see SubjectAttributes.

§universal: Universal<'a>

Deployment and clock facts a policy may reference — see Universal.

§client_id: Option<&'a ClientId>

The application whose OAuth token presented the write. None when the account wrote with its own credential.

§collection: &'a str

The collection (NSID) being written.

§action: WriteAction

Create, update or delete — see WriteAction.

§diff: Diff<'a>

What changed.

§before: Option<&'a Value>

The whole record as it was before this write, or None when the key held nothing.

Diff::changes is the index key and says what moved; this is the record itself. An evaluator that reads fields rather than changed paths reads them from here, because a record cannot be recovered from a diff: a path string is not a parse of the key that produced it, so two different fields can spell the same path, and an update’s diff names only the fields it touched.

§after: Option<&'a Value>

The whole record as this write leaves it, or None for a delete. See before.

§lookups: &'a [Lookup<'a>]

What the policies applicable to this write declared they read, and what was found. See Lookup. Empty when no applicable policy declares one, which is the ordinary case.

§

Blob

A blob uploaded to this account. It is judged when the upload starts, on what the request claims; at checkpoints while the body arrives, each of which can refuse the upload but not admit it; and once the bytes are in and before they are stored. A fact the first judgment does not have is None — what is not known yet cannot deny.

Fields

§account: &'a str

The account the blob is uploaded to.

§attributes: SubjectAttributes<'a>

Other attributes of that account — see SubjectAttributes.

§universal: Universal<'a>

Deployment and clock facts — see Universal.

§client_id: Option<&'a ClientId>

The application whose OAuth token presented the upload. None when the account uploaded with its own credential.

§mime_type: &'a str

The MIME type the uploader declared.

§sniffed: Option<&'a str>

The MIME type read from the blob’s own bytes. None before the body is read.

§size: Option<u64>

The blob’s size in bytes. Before the body, the length the request declared, or None when it declared none. While the body arrives, that length, or the bytes received so far when there is none. After, what arrived.

§

Grant

A pushed authorization request, judged on the application and the scopes it asks for, before any account is known.

It names no account because it is asked before the request’s login_hint is resolved, which is what keeps a client the gate refuses indistinguishable from a hint naming nobody — so only a policy bound to the whole server reaches it. A rule about one account is asked where the account is known: Subject::Token, on every token issue and every rotation, and Subject::Write.

Fields

§universal: Universal<'a>

Deployment and clock facts a policy may reference — see Universal.

§client_id: &'a ClientId

The application requesting the grant.

§requested_scopes: &'a [&'a str]

The scopes it is asking for.

§

Token

A token about to be issued to an application for an account: an authorization code exchanged, or a refresh token rotated.

Fields

§account: &'a str

The account the token would authenticate as.

§attributes: SubjectAttributes<'a>

Other attributes of that account — see SubjectAttributes.

§universal: Universal<'a>

Deployment and clock facts — see Universal.

§client_id: &'a ClientId

The application the token would be issued to.

§scopes: &'a [&'a str]

The scopes the token would carry.

§

Create

Where a new account lands: account.create, asked once for each pool and zone a create could land in, before a name is made.

Fields

§account: &'a str

The account creating it. The operator’s own create names the operator’s DID, which this server does not host.

§attributes: Option<SubjectAttributes<'a>>

Other attributes of the creating account, when this server hosts it — see SubjectAttributes.

§universal: Universal<'a>

Deployment and clock facts — see Universal.

§kind: SubjectKind<'a>

What the new account is.

§asked: Asked

How the create asked for its name.

§pool: &'a str

The pool the name would come from.

§zone: &'a str

The zone it would sit under.

§name: Option<&'a str>

The whole name, when the create gave one. A name the pool makes does not exist yet when this is asked.

§label: Option<&'a str>

The name’s label under zone, when the create gave a name.

Implementations§

Source§

impl Subject<'_>

Source

pub fn client_id(&self) -> Option<&ClientId>

The application presenting this subject, if one is.

Source

pub fn lookups(&self) -> &[Lookup<'_>]

What this write’s applicable policies read from other repositories. Empty for every subject that is not a write, since only a write names anybody.

Source

pub fn universal(&self) -> &Universal<'_>

Deployment and clock facts, common to every variant — see Universal.

Trait Implementations§

Source§

impl<'a> Clone for Subject<'a>

Source§

fn clone(&self) -> Subject<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Subject<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for Subject<'a>

Source§

fn eq(&self, other: &Subject<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Copy for Subject<'a>

Source§

impl<'a> Eq for Subject<'a>

Source§

impl<'a> StructuralPartialEq for Subject<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Subject<'a>

§

impl<'a> RefUnwindSafe for Subject<'a>

§

impl<'a> Send for Subject<'a>

§

impl<'a> Sync for Subject<'a>

§

impl<'a> Unpin for Subject<'a>

§

impl<'a> UnsafeUnpin for Subject<'a>

§

impl<'a> UnwindSafe for Subject<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.