pub struct Token { /* private fields */ }
Expand description
Token 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 Token authentication you also need:
- Existing authentication token.
- Name of the project to use.
- Domain of the project.
Start with creating a Token
object using new, then add a project scope
with with_project_scope:
use osauth::common::IdOrName;
let auth = osauth::identity::Token::new(
"https://cloud.local/identity",
"<a token>",
)
.expect("Invalid auth_url")
.with_project_scope(IdOrName::from_name("project1"), IdOrName::from_id("default"));
let session = osauth::Session::new(auth);
The authentication token is cached while it’s still valid or until
refresh is called.
Clones of a Token
also start with an empty cache.
Implementations§
source§impl Token
impl Token
sourcepub fn new<U, S>(auth_url: U, token: S) -> Result<Token, Error>where
U: AsRef<str>,
S: Into<String>,
pub fn new<U, S>(auth_url: U, token: S) -> Result<Token, Error>where U: AsRef<str>, S: Into<String>,
Create a token authentication.
sourcepub fn set_project_scope(
&mut self,
project: IdOrName,
domain: impl Into<Option<IdOrName>>
)
pub fn set_project_scope( &mut self, project: IdOrName, domain: impl Into<Option<IdOrName>> )
Scope authentication to the given project.
A convenience wrapper around set_scope
.
sourcepub fn set_scope(&mut self, scope: Scope)
pub fn set_scope(&mut self, scope: Scope)
Add a scope to the authentication.
This is required in the most cases.
sourcepub fn with_project_scope(
self,
project: IdOrName,
domain: impl Into<Option<IdOrName>>
) -> Token
pub fn with_project_scope( self, project: IdOrName, domain: impl Into<Option<IdOrName>> ) -> Token
Scope authentication to the given project.
A convenience wrapper around with_scope
.
sourcepub fn with_scope(self, scope: Scope) -> Token
pub fn with_scope(self, scope: Scope) -> Token
Add a scope to the authentication.
Trait Implementations§
source§impl AuthType for Token
impl AuthType for Token
source§fn authenticate<'life0, 'life1, 'async_trait>(
&'life0 self,
client: &'life1 Client,
request: RequestBuilder
) -> Pin<Box<dyn Future<Output = Result<RequestBuilder, Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
Token: 'async_trait,
fn authenticate<'life0, 'life1, 'async_trait>( &'life0 self, client: &'life1 Client, request: RequestBuilder ) -> Pin<Box<dyn Future<Output = Result<RequestBuilder, Error>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, 'life1: 'async_trait, Token: 'async_trait,
Authenticate a request.
source§fn get_endpoint<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
client: &'life1 Client,
service_type: &'life2 str,
filters: &'life3 EndpointFilters
) -> Pin<Box<dyn Future<Output = Result<Url, Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Token: 'async_trait,
fn get_endpoint<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, client: &'life1 Client, service_type: &'life2 str, filters: &'life3 EndpointFilters ) -> Pin<Box<dyn Future<Output = Result<Url, Error>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Token: 'async_trait,
Get a URL for the requested service.