Module openstack::auth [] [src]

Authentication modules.

Usually, accessing OpenStack services requires authentication. This module provides a way to authenticate against an Identity service, as well as simple authentication implementations for standalone use.

The usual workflow for connecting to OpenStack API is as follows:

  1. Create a suitable authentication method.
  2. Populate it with authentication data (credentials, etc).
  3. Create a Session by using the Session constructor.
  4. Pass a reference to the resulting session to various API managers.

Using password authentication

Start with creating an Identity object which will guide you through setting all necessary values. PasswordAuth is the actual implementation of the authentication method trait.

Note that as of now, only project-scoped tokens are supported. An attempt to create unscoped tokens always fails. This restriction may be lifted in the future.

Examples

Creating an authentication method using project-scoped tokens:

use openstack::auth::Identity;
use openstack::Session;

let auth = Identity::new("https://my.cloud.com/identity").unwrap()
    .with_user("admin", "pa$$w0rd", "My Domain")
    .with_project_scope("project1", "My Domain")
    .create().expect("Failed to authenticate");
let session = Session::new(auth);

Creating an authentication method from environment variables:

use openstack::auth::Identity;
use openstack::Session;

let auth = Identity::from_env().expect("Failed to authenticate");
let session = Session::new(auth);

Creating a dummy authentication method for use against clouds that do not have actual authentication:

use openstack::auth::NoAuth;
use openstack::Session;

let auth = NoAuth::new("https://my.cloud.com/some-service").unwrap();
let session = Session::new(auth);

Limitations

  • Only Identity API v3 is supported and planned for support.

Structs

Identity

Authentication method factory using Identity API V3.

NoAuth

Authentication method that provides no authentication.

PasswordAuth

Password authentication using Identity API V3.

Traits

AuthMethod

Trait for an authentication method.

BoxedClone

Helper trait to allow cloning of sessions.