[][src]Struct osauth::identity::Password

pub struct Password { /* fields omitted */ }

Password authentication using Identity API V3.

For any Identity authentication you need to know auth_url, which is an authentication endpoint of the Identity service. For the Password authentication you also need:

  1. User name and password.
  2. Domain of the user.
  3. Name of the project to use.
  4. Domain of the project.

Note: currently only names are supported for user, user domain and project domain. ID support is coming later.

Start with creating a Password object using new, then add a project scope with with_project_scope:

let auth = osauth::identity::Password::new(
    "https://cloud.local/identity",
    "admin",
    "pa$$w0rd",
    "Default"
)
.expect("Invalid auth_url")
.with_project_scope(IdOrName::Name("project1".to_string()), None);

let session = osauth::Session::new(auth);

If your cloud has several regions, pick one using with_region:

use osauth::identity::IdOrName;

let scope = osauth::identity::Scope::Project {
    project: IdOrName::Name("project1".to_string()),
    domain: Some(IdOrName::Id("default".to_string())),
};
let auth = osauth::identity::Password::new(
    "https://cloud.local/identity",
    "admin",
    "pa$$w0rd",
    "Default"
)
.expect("Invalid auth_url")
.with_scope(scope)
.with_region("US-East");

let session = osauth::Session::new(auth);

By default, the public endpoint interface is used. f you would prefer to default to another one, you can set it with with_default_endpoint_interface.

use osauth::identity::IdOrName;

let scope = osauth::identity::Scope::Project {
    project: IdOrName::Name("project1".to_string()),
    domain: Some(IdOrName::Id("default".to_string())),
};
let auth = osauth::identity::Password::new(
    "https://cloud.local/identity",
    "admin",
    "pa$$w0rd",
    "Default"
)
.expect("Invalid auth_url")
.with_scope(scope)
.with_default_endpoint_interface(osauth::InterfaceType::Internal);

The authentication token is cached while it's still valid or until refresh is called. Clones of a Password also start with an empty cache.

Implementations

impl Password[src]

pub fn new<U, S1, S2, S3>(
    auth_url: U,
    user_name: S1,
    password: S2,
    user_domain_name: S3
) -> Result<Password, Error> where
    U: IntoUrl,
    S1: Into<String>,
    S2: Into<String>,
    S3: Into<String>, 
[src]

Create a password authentication.

pub fn new_with_client<U, S1, S2, S3>(
    auth_url: U,
    client: Client,
    user_name: S1,
    password: S2,
    user_domain_name: S3
) -> Result<Password, Error> where
    U: IntoUrl,
    S1: Into<String>,
    S2: Into<String>,
    S3: Into<String>, 
[src]

Create a password authentication with the provided HTTP client.

pub fn endpoint_filters(&self) -> &EndpointFilters[src]

Endpoint filters.

pub fn endpoint_filters_mut(&mut self) -> &mut EndpointFilters[src]

Mutable endpoint filters.

pub fn set_default_endpoint_interface(
    &mut self,
    endpoint_interface: InterfaceType
)
[src]

Set the default endpoint interface to use.

pub fn set_endpoint_filters(&mut self, filters: EndpointFilters)[src]

Set endpoint filters.

pub fn set_region<S>(&mut self, region: S) where
    S: Into<String>, 
[src]

👎 Deprecated since 0.3.0:

Use set_filters or filters_mut

Set a region for this authentication method.

pub fn set_project_scope(
    &mut self,
    project: IdOrName,
    domain: impl Into<Option<IdOrName>>
)
[src]

Scope authentication to the given project.

A convenience wrapper around set_scope.

pub fn set_scope(&mut self, scope: Scope)[src]

Add a scope to the authentication.

This is required in the most cases.

pub fn with_default_endpoint_interface(
    self,
    endpoint_interface: InterfaceType
) -> Self
[src]

Convert this authentication into one using the given endpoint interface.

pub fn with_endpoint_filters(self, filters: EndpointFilters) -> Self[src]

Add endpoint filters.

pub fn with_project_scope(
    self,
    project: IdOrName,
    domain: impl Into<Option<IdOrName>>
) -> Password
[src]

Scope authentication to the given project.

A convenience wrapper around with_scope.

pub fn with_region<S>(self, region: S) -> Self where
    S: Into<String>, 
[src]

Set a region for this authentication method.

pub fn with_scope(self, scope: Scope) -> Self[src]

Add a scope to the authentication.

pub fn user(&self) -> &IdOrName[src]

User name or ID.

pub fn project(&self) -> Option<&IdOrName>[src]

Project name or ID (if project scoped).

Trait Implementations

impl AuthType for Password[src]

fn default_filters(&self) -> Option<&EndpointFilters>[src]

Endpoint filters in use.

fn request<'life0, 'async_trait>(
    &'life0 self,
    method: Method,
    url: Url
) -> Pin<Box<dyn Future<Output = Result<RequestBuilder, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Create an authenticated request.

fn get_endpoint<'life0, 'async_trait>(
    &'life0 self,
    service_type: String,
    filters: EndpointFilters
) -> Pin<Box<dyn Future<Output = Result<Url, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Get a URL for the requested service.

fn refresh<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Refresh the cached token and service catalog.

impl Clone for Password[src]

impl Debug for Password[src]

impl Identity for Password[src]

Auto Trait Implementations

impl !RefUnwindSafe for Password

impl Send for Password

impl Sync for Password

impl Unpin for Password

impl !UnwindSafe for Password

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.