[−][src]Struct osauth::identity::Password
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:
- User name and password.
- Domain of the user.
- Name of the project to use.
- 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::from_name("project1"), IdOrName::from_id("default")); 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::from_name("project1"), domain: Some(IdOrName::from_id("default")), }; 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::from_name("project1"), domain: Some(IdOrName::from_id("default")), }; 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]
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>,
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]
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>,
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]
&mut self,
endpoint_interface: InterfaceType
)
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]
S: Into<String>,
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]
&mut self,
project: IdOrName,
domain: impl Into<Option<IdOrName>>
)
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]
self,
endpoint_interface: InterfaceType
) -> Self
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]
self,
project: IdOrName,
domain: impl Into<Option<IdOrName>>
) -> Password
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]
S: Into<String>,
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]
&'life0 self,
method: Method,
url: Url
) -> Pin<Box<dyn Future<Output = Result<RequestBuilder, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
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]
&'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,
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]
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,