Module oxide_auth::primitives

source ·
Expand description

A collection of primites useful for more than one authorization method.

A primitive is the smallest independent unit of policy used in OAuth related endpoints. For example, an authorizer generates and verifies Authorization Codes. There only is, as you might have noticed, only the OAuth2 code grant method. But abstracting away the underlying primitives makes it possible to provide –e.g.– a independent database based implementation.

These should be used to build or instantiate an Endpoint, for example Generic or your own.

use oxide_auth::frontends::simple::endpoint::Generic;
use oxide_auth::primitives::{
    authorizer::AuthMap,
    generator::RandomGenerator,
    issuer::TokenMap,
    registrar::ClientMap,
};

Generic {
    authorizer: AuthMap::new(RandomGenerator::new(16)),
    registrar: ClientMap::new(),
    issuer: TokenMap::new(RandomGenerator::new(16)),
    // ...
};

Modules

  • Authorizers are need to exchange code grants for bearer tokens.
  • Generators produce string code grant and bearer tokens for a determined grant.
  • Encapsulates various shared mechanisms for handlings different grants.
  • Generates bearer tokens and refresh tokens.
  • Commonly used primitives for frontends and backends.
  • Registrars administer a database of known clients.
  • Defines the Scope type and parsing/formatting according to the rfc.