auth

package
v0.0.0-...-78eb850 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 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)
	GetTokenId() (string, error)
	SetLocalTokenExpire(expire int)
	GetServiceEndpoint(sType string, sName string, sInterface string) (string, error)
	TokenIssue() error
	Region() string
	AuthRequest(req *resty.Request) error
	GetSafeHeader(header http.Header) http.Header
	GetProjectId() (string, error)
	IsAdmin() bool
}

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
	LocalTokenExpireSecond 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 *resty.Request) error

func (PasswordAuthPlugin) GetProjectId

func (plugin PasswordAuthPlugin) GetProjectId() (string, error)

func (PasswordAuthPlugin) GetSafeHeader

func (plugin PasswordAuthPlugin) GetSafeHeader(header http.Header) http.Header

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) IsAdmin

func (plugin PasswordAuthPlugin) IsAdmin() bool

func (PasswordAuthPlugin) Region

func (plugin PasswordAuthPlugin) Region() string

func (PasswordAuthPlugin) SetHttpTimeout

func (plugin PasswordAuthPlugin) SetHttpTimeout(timeout int) *PasswordAuthPlugin

func (*PasswordAuthPlugin) SetLocalTokenExpire

func (plugin *PasswordAuthPlugin) SetLocalTokenExpire(expireSeconds 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"`
	Tags        []string `json:"tags,omitempty"`
	IsDomain    bool     `json:"is_domain,omitempty"`
	ParentId    string   `json:"parent_id,omitempty"`
}

type RespToken

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

type Role

type Role struct {
	Id   string `json:"id"`
	Name string `json:"name"`
}

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"`
	Catalogs  []Catalog `json:"catalog"`
	Roles     []Role    `json:"roles"`
	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