auth

package
v2.1.23+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2018 License: Apache-2.0, Apache-2.0 Imports: 10 Imported by: 157

Documentation

Index

Constants

View Source
const (
	AUTH_TOKEN = appctx.AppContextKey("X_AUTH_TOKEN")
)

Variables

This section is empty.

Functions

func AdminCredential

func AdminCredential() mcclient.TokenCredential

func AdminSession

func AdminSession(region, zone, endpointType, apiVersion string) *mcclient.ClientSession

func AsyncInit

func AsyncInit(info *AuthInfo, debug, insecure bool, callback AuthCompletedCallback)

func Client

func Client() *mcclient.Client

func FetchUserCredential

func FetchUserCredential(ctx context.Context) mcclient.TokenCredential

func GetAdminSession

func GetAdminSession(region string, apiVersion string) *mcclient.ClientSession

func GetServiceURL

func GetServiceURL(service, region, zone, endpointType string) (string, error)

func GetSession

func GetSession(token mcclient.TokenCredential, region string, apiVersion string) *mcclient.ClientSession

func GetTokenString

func GetTokenString() string

func Init

func Init(info *AuthInfo, debug, insecure bool)

func IsAuthed

func IsAuthed() bool

func SetTimeout

func SetTimeout(t time.Duration)

func Verify

func Verify(tokenId string) (mcclient.TokenCredential, error)

Types

type AuthCompletedCallback

type AuthCompletedCallback func()

func (*AuthCompletedCallback) Run

func (callback *AuthCompletedCallback) Run()

type AuthInfo

type AuthInfo struct {
	AuthUrl string
	// Domain not need when v2 auth
	Domain   string
	Username string
	Passwd   string
	// Project is tenant when v2 auth
	Project string
}

func NewAuthInfo

func NewAuthInfo(authUrl, domain, user, passwd, project string) *AuthInfo

func NewV2AuthInfo

func NewV2AuthInfo(authUrl, user, passwd, tenant string) *AuthInfo

type TokenCacheVerify

type TokenCacheVerify struct {
	*cache.LRUCache
}

func NewTokenCacheVerify

func NewTokenCacheVerify() *TokenCacheVerify

func (*TokenCacheVerify) AddToken

func (c *TokenCacheVerify) AddToken(cred mcclient.TokenCredential) error

func (*TokenCacheVerify) DeleteToken

func (c *TokenCacheVerify) DeleteToken(token string) bool

func (*TokenCacheVerify) GetToken

func (c *TokenCacheVerify) GetToken(token string) (mcclient.TokenCredential, bool)

func (*TokenCacheVerify) Verify

func (c *TokenCacheVerify) Verify(cli *mcclient.Client, adminToken, token string) (mcclient.TokenCredential, error)

Jump to

Keyboard shortcuts

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