auth

package
v0.0.0-...-2ab8be3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONTENT_TYPE string = "application/json"

	TYPE_COMPUTE   string = "compute"
	TYPE_VOLUME    string = "volume"
	TYPE_VOLUME_V2 string = "volumev2"
	TYPE_VOLUME_V3 string = "volumev3"
	TYPE_IDENTITY  string = "identity"
	TYPE_IMAGE     string = "image"
	TYPE_NETWORK   string = "network"

	INTERFACE_PUBLIC   string = "public"
	INTERFACE_ADMIN    string = "admin"
	INTERFACE_INTERVAL string = "internal"

	URL_AUTH_TOKEN string = "/auth/tokens"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Identity Identity `json:"identity,omitempty"`
	Scope    Scope    `json:"scope,omitempty"`
}

type AuthBody

type AuthBody struct {
	Auth Auth `json:"auth"`
}

type AuthPlugin

type AuthPlugin interface {
	GetToken() (*Token, error)
	SetTokenExpireSecond(expire int)
	GetAuthTokenId() string
	GetTokenId() (string, error)
	GetServiceEndpoint(sType string, sName string, sInterface string) (string, error)
	TokenIssue() error
	AuthRequest(req *http.Request) error
	Region() string
}

type Catalog

type Catalog struct {
	Type      string     `json:"type"`
	Name      string     `json:"name"`
	Id        string     `json:"id"`
	Endpoints []Endpoint `json:"endpoints"`
}

type Domain

type Domain struct {
	Id   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

type Endpoint

type Endpoint struct {
	Id        string `json:"id"`
	Region    string `json:"region"`
	Url       string `json:"url"`
	Interface string `json:"interface"`
	RegionId  string `json:"region_id"`
	ServiceId string `json:"service_id"`
}

type Identity

type Identity struct {
	Methods  []string `json:"methods,omitempty"`
	Password Password `json:"password,omitempty"`
}

type Password

type Password struct {
	User User `json:"user"`
}

type PasswordAuthPlugin

type PasswordAuthPlugin struct {
	AuthUrl           string
	Username          string
	Password          string
	ProjectName       string
	UserDomainName    string
	ProjectDomainName string
	RegionName        string
	TokenExpireSecond int
	// contains filtered or unexported fields
}

func NewPasswordAuth

func NewPasswordAuth(authUrl string, user User, project Project, regionName string) PasswordAuthPlugin

func (*PasswordAuthPlugin) AuthRequest

func (plugin *PasswordAuthPlugin) AuthRequest(req *http.Request) error

func (PasswordAuthPlugin) Delete

func (plugin PasswordAuthPlugin) Delete(url string,
	headers map[string]string) (*utility.Response, error)

func (PasswordAuthPlugin) Get

func (plugin PasswordAuthPlugin) Get(url string, query url.Values,
	headers map[string]string) (*utility.Response, error)

func (PasswordAuthPlugin) GetAuthTokenId

func (plugin PasswordAuthPlugin) GetAuthTokenId() string

func (*PasswordAuthPlugin) GetServiceEndpoint

func (plugin *PasswordAuthPlugin) GetServiceEndpoint(
	serviceType string, serviceName string, serviceInterface string,
) (string, error)

func (PasswordAuthPlugin) GetToken

func (plugin PasswordAuthPlugin) GetToken() (*Token, error)

func (*PasswordAuthPlugin) GetTokenId

func (plugin *PasswordAuthPlugin) GetTokenId() (string, error)

func (PasswordAuthPlugin) Post

func (plugin PasswordAuthPlugin) Post(url string, body []byte,
	headers map[string]string) (*utility.Response, error)

func (PasswordAuthPlugin) Put

func (plugin PasswordAuthPlugin) Put(url string, body []byte,
	headers map[string]string) (*utility.Response, error)

func (PasswordAuthPlugin) Region

func (plugin PasswordAuthPlugin) Region() string

func (PasswordAuthPlugin) Request

func (plugin PasswordAuthPlugin) Request(req *http.Request) (*utility.Response, error)

func (*PasswordAuthPlugin) SetHttpTimeout

func (plugin *PasswordAuthPlugin) SetHttpTimeout(timeout int)

func (*PasswordAuthPlugin) SetTokenExpireSecond

func (plugin *PasswordAuthPlugin) SetTokenExpireSecond(expire int)

func (*PasswordAuthPlugin) TokenIssue

func (plugin *PasswordAuthPlugin) TokenIssue() error

type Project

type Project struct {
	Id          string `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	Domain      Domain `json:"domain,omitempty"`
	Description string `json:"description,omitempty"`
	Enabled     bool   `json:"enabled,omitempty"`
	DomainId    string `json:"domain_id,omitempty"`
}

type RespToken

type RespToken struct {
	Token         Token `json:"token"`
	XSubjectToken string
}

type Scope

type Scope struct {
	Project Project `json:"project,omitempty"`
}

type Token

type Token struct {
	IsDomain  bool      `json:"is_domain"`
	Methods   []string  `json:"methods"`
	ExpiresAt string    `json:"expires_at"`
	Name      bool      `json:"name"`
	Catalogs  []Catalog `json:"catalog"`
	Project   Project
	User      User
}

type TokenCache

type TokenCache struct {
	TokenId string
	// contains filtered or unexported fields
}

func (*TokenCache) GetServiceEndpoints

func (tc *TokenCache) GetServiceEndpoints(serviceType string, serviceName string) []Endpoint

func (*TokenCache) IsTokenExpired

func (tc *TokenCache) IsTokenExpired() bool

type User

type User struct {
	Id          string `json:"id,omitempty"`
	Name        string `json:"name"`
	Password    string `json:"password"`
	Project     string `json:"project,omitempty"`
	Description string `json:"description,omitempty"`
	Email       string `json:"email,omitempty"`
	Enabled     bool   `json:"enabled,omitempty"`
	Domain      Domain `json:"domain"`
	DomainId    string `json:"domain_id,omitempty"`
}

Jump to

Keyboard shortcuts

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