pub struct AllowKeysAuthorizationHandler { /* private fields */ }
Expand description

A file-backed authorization handler that permits admin keys

The authorization handler only accepts Identity::Key identities; if a different type of identity is provided, the handler will return AuthorizationHandlerResult::Continue. If a key is provided, the handler will check if the key is present in the backing file. If the key is in the backing file, the handler will return AuthorizationHandlerResult::Allow; if not, it will return AuthorizationHandlerResult::Continue. The permission_id argument for AuthorizationHandler::has_permission is ignored because this authorization handler provides admin privileges (all permissions).

The authorization handler’s backing file must be a list of keys separated by newlines.

The list of keys in the file are cached in-memory by the authorization handler; this means that the handler will not have to read from the file every time permissions are checked. Instead, each time the handler checks for permissions, it will check the backing file for any changes since the last read, refreshing the internal cache if necessary. If the backing file does not exist, is removed, or becomes unavailable, the authorization handler will treat the list of keys as empty (all permission checks will receive a AuthorizationHandlerResult::Continue result).

Implementations

Constructs a new AllowKeysAuthorizationHandler.

Arguments
  • file_path - The path of the backing allow keys file.

Trait Implementations

Determines if the given identity has the requested permission

Clone implementation for AuthorizationHandler. The implementation of the Clone trait for Box<dyn AuthorizationHandler> calls this method. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Convert self to an expression for Diesel’s query builder. Read more

Convert &self to an expression for Diesel’s query builder. Read more

Should always be Self

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more