goraxauth

package module
v0.0.0-...-0163e8e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

README

goraxauth

A gophercloud compatible authentication helper for Rackspace Customer Identity.

This initial version only adds support for the Rackspace API KEY and does not support password authentication for MFA enabled accounts.

WARNING

This is not yet supported upstream by gophercloud. For backwards compatible support gophercloud/gophercloud#3030 has been opened. To make use of this change run the following in your project:

go mod edit -replace github.com/gophercloud/gophercloud=github.com/cardoe/gophercloud@go-v1-fix-auth-v2

Usage

Replace any usage of github.com/gophercloud/gophercloud/openstack/identity/v2/tokens.AuthOptions with goraxauth.AuthOptions. This struct adds the ApiKey field which is the users Rackspace API Key.

The following functions from the docs for gophercloud on go.dev examples are replaced by functions from goraxauth.

import (
    "github.com/gophercloud/gophercloud/openstack"
    "github.com/rackerlabs/goraxauth"
)

// old functions
opts, err := openstack.AuthOptionsFromEnv()
provider, err := openstack.AuthenticatedClient(opts)

// replacements
opts, err := goraxauth.AuthOptionsFromEnv()
provider, err := goraxauth.AuthenticatedClient(opts)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthenticatedClient

func AuthenticatedClient(options AuthOptions) (*gophercloud.ProviderClient, error)

Types

type AuthOptions

type AuthOptions struct {
	tokens2.AuthOptions
	ApiKey string `json:"apiKey,omitempty"`
}

func AuthOptionsFromEnv

func AuthOptionsFromEnv() (AuthOptions, error)

AuthOptionsFromEnv fills out a goraxauth.AuthOptionsRax structure with the settings found on the various OpenStack OS_* environment variables and/or the RAX_API_KEY environment variable.

The following variables provide sources of truth: OS_AUTH_URL, OS_USERNAME, OS_PASSWORD, RAX_API_KEY and OS_PROJECT_ID.

Of these, OS_USERNAME and OS_PASSWORD or RAX_API_KEY must have settings, or an error will result, while OS_PROJECT_ID is optional.

OS_TENANT_ID is the deprecated forms of OS_PROJECT_ID.

If OS_PROJECT_ID, they will still be referred as "tenant".

To use this function, first set the OS_* environment variables (for example, by sourcing an `openrc` file), then:

opts, err := openstack.AuthOptionsFromEnv()
provider, err := openstack.AuthenticatedClient(context.TODO(), opts)

func (AuthOptions) CanReauth

func (opts AuthOptions) CanReauth() bool

func (AuthOptions) ToTokenV2CreateMap

func (opts AuthOptions) ToTokenV2CreateMap() (map[string]interface{}, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL