Skip to main content

LinksTokenTable

Struct LinksTokenTable 

Source
pub struct LinksTokenTable<L: NamedTypeLinks> { /* private fields */ }
Expand description

The tokens a links server knows, stored as links (issue #149): the authenticator of (auth: token) that clink --tokens uses.

A subject s of the data has a pair (p: Token s), where Token is the point named Token, and each of its tokens is a link (t: p t), named sha256:<hex> after the SHA-256 of the token, so the store never holds a token itself. The table lives in a store of its own or in the data; any other authenticator is a callback of LinksSessions.

Implementations§

Source§

impl<L: NamedTypeLinks> LinksTokenTable<L>

Source

pub const TOKEN_NAME: &'static str = "Token"

The name of the point every token link starts from.

Source

pub fn new(store: L) -> Self

Source

pub fn store(&self) -> &L

Source

pub fn store_mut(&mut self) -> &mut L

Source

pub fn into_inner(self) -> L

Source

pub fn name_of(token: &str) -> String

The name of the link of token.

Source

pub fn authenticate(&mut self, token: &str) -> Result<Option<u32>>

The subject of token, or None when the table does not know it.

Source

pub fn grant(&mut self, token: &str, subject: u32) -> Result<u32>

Lets token authenticate as subject, instead of any subject it had.

Returns the link of the token.

Source

pub fn revoke(&mut self, token: &str) -> Result<bool>

Forgets token; whether the table knew it.

Auto Trait Implementations§

§

impl<L> Freeze for LinksTokenTable<L>
where L: Freeze,

§

impl<L> RefUnwindSafe for LinksTokenTable<L>
where L: RefUnwindSafe,

§

impl<L> Send for LinksTokenTable<L>
where L: Send,

§

impl<L> Sync for LinksTokenTable<L>
where L: Sync,

§

impl<L> Unpin for LinksTokenTable<L>
where L: Unpin,

§

impl<L> UnsafeUnpin for LinksTokenTable<L>
where L: UnsafeUnpin,

§

impl<L> UnwindSafe for LinksTokenTable<L>
where L: UnwindSafe,

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.