iam

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

View Source
const (
	GrantTypePassword              authentication.GrantType = "password"
	GrantTypeAPIKey                authentication.GrantType = "urn:ibm:params:oauth:grant-type:apikey"
	GrantTypeOnetimePasscode       authentication.GrantType = "urn:ibm:params:oauth:grant-type:passcode" // #nosec G101
	GrantTypeAuthorizationCode     authentication.GrantType = "authorization_code"
	GrantTypeRefreshToken          authentication.GrantType = "refresh_token"
	GrantTypeDelegatedRefreshToken authentication.GrantType = "urn:ibm:params:oauth:grant-type:delegated-refresh-token" // #nosec G101
	GrantTypeIdentityCookie        authentication.GrantType = "urn:ibm:params:oauth:grant-type:identity-cookie"
	GrantTypeDerive                authentication.GrantType = "urn:ibm:params:oauth:grant-type:derive"
)

Grant types

View Source
const (
	ResponseTypeIAM                   authentication.ResponseType = "cloud_iam"
	ResponseTypeUAA                   authentication.ResponseType = "uaa"
	ResponseTypeIMS                   authentication.ResponseType = "ims_portal"
	ResponseTypeDelegatedRefreshToken authentication.ResponseType = "delegated_refresh_token" // #nosec G101
)

Response types

Variables

This section is empty.

Functions

func APIKeyTokenRequest

func APIKeyTokenRequest(apikey string, opts ...authentication.TokenOption) *authentication.TokenRequest

func AuthorizationTokenRequest

func AuthorizationTokenRequest(code string, redirectURI string, opts ...authentication.TokenOption) *authentication.TokenRequest

func OnetimePasscodeTokenRequest

func OnetimePasscodeTokenRequest(passcode string, opts ...authentication.TokenOption) *authentication.TokenRequest

func PasswordTokenRequest

func PasswordTokenRequest(username, password string, opts ...authentication.TokenOption) *authentication.TokenRequest

func RefreshTokenRequest

func RefreshTokenRequest(refreshToken string, opts ...authentication.TokenOption) *authentication.TokenRequest

func SetAccount

func SetAccount(accountID string) authentication.TokenOption

func SetIMSAccount

func SetIMSAccount(imsAccountID string) authentication.TokenOption

func SetPhoneAuthToken

func SetPhoneAuthToken(token string) authentication.TokenOption

func SetSecurityCode

func SetSecurityCode(code string, vendor MFAVendor) authentication.TokenOption

func SetSecurityQuestion

func SetSecurityQuestion(questionID int, answer string) authentication.TokenOption

func SetTOTPCode

func SetTOTPCode(code string) authentication.TokenOption

func SetVeriSignCode

func SetVeriSignCode(code string) authentication.TokenOption

Types

type APIError

type APIError struct {
	ErrorCode    string      `json:"errorCode"`
	ErrorMessage string      `json:"errorMessage"`
	ErrorDetails string      `json:"errorDetails"`
	Requirements Requirement `json:"requirements"`
}

type Config

type Config struct {
	IAMEndpoint     string
	TokenEndpoint   string // Optional. Default value is <IAMEndpoint>/identity/token
	ClientID        string
	ClientSecret    string
	UAAClientID     string
	UAAClientSecret string
}

func DefaultConfig

func DefaultConfig(iamEndpoint string) Config

type Endpoint

type Endpoint struct {
	AuthURL     string `json:"authorization_endpoint"`
	TokenURL    string `json:"token_endpoint"`
	PasscodeURL string `json:"passcode_endpoint"`
}

type Interface

type Interface interface {
	GetEndpoint() (*Endpoint, error)
	GetToken(req *authentication.TokenRequest) (*Token, error)
	InitiateIMSPhoneFactor(req *authentication.TokenRequest) (authToken string, err error)
}

func NewClient

func NewClient(config Config, restClient *rest.Client) Interface

type MFAVendor

type MFAVendor string
const (
	MFAVendorVerisign    MFAVendor = "VERISIGN"
	MFAVendorTOTP        MFAVendor = "TOTP"
	MFAVendorPhoneFactor MFAVendor = "PHONE_FACTOR"
)

MFA vendors

func (MFAVendor) String

func (m MFAVendor) String() string

type Requirement

type Requirement struct {
	ErrorCode    string `json:"code"`
	ErrorMessage string `json:"error"`
}

type Token

type Token struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	TokenType    string    `json:"token_type"`
	Scope        string    `json:"scope"`
	Expiry       time.Time `json:"expiration"`

	// Fields present when ResponseTypeUAA is set
	UAAToken        string `json:"uaa_token"`
	UAARefreshToken string `json:"uaa_refresh_token"`

	// Fields present when ResponseTypeIMS is set
	IMSUserID int64  `json:"ims_user_id"`
	IMSToken  string `json:"ims_token"`
}

Jump to

Keyboard shortcuts

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