Module openstack::auth

source ·
Expand description

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 Cloud.

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;

let auth = openstack::auth::Password::new(
        "https://my.cloud.com/identity",
        "admin", "pa$$w0rd", "domain.com")
    .expect("Invalid authentication URL")
    .with_project_scope("project1", "domain.com");
let os = openstack::Cloud::new(auth);

Creating a session and a cloud from environment variables:

use openstack;

let session = openstack::auth::from_env().expect("Failed to authenticate");
let os = openstack::Cloud::from(session);

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

use openstack;

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

Limitations

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

Structs

Authentication method that provides no authentication.
Password authentication using Identity API V3.

Traits

Trait for an authentication method.
Helper trait to allow cloning of sessions.
Generic trait for authentication using Identity API V3.

Functions

Create a Session from the config file.
Create a Session from environment variables.