iam

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GrantTypePassword              authentication.GrantType = "password"                                 // #nosec G101
	GrantTypeAPIKey                authentication.GrantType = "urn:ibm:params:oauth:grant-type:apikey"   // #nosec G101
	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"
	GrantTypeCRToken               authentication.GrantType = "urn:ibm:params:oauth:grant-type:cr-token" // #nosec G101
)

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

View Source
const (
	InvalidTokenErrorCode           = "BXNIM0407E" // #nosec G101
	RefreshTokenExpiryErrorCode     = "BXNIM0408E" // #nosec G101
	ExternalAuthenticationErrorCode = "BXNIM0400E"
	SessionInactiveErrorCode        = "BXNIM0439E"
)

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 CRTokenRequest added in v0.6.8

func CRTokenRequest(crToken string, profileID string, profileName string, opts ...authentication.TokenOption) *authentication.TokenRequest

CRTokenRequest builds a 'TokenRequest' struct from the user input. The value of 'crToken' is set as the value of the 'cr_token' form parameter of the request. 'profileID' and 'profileName' are optional parameters used to set the 'profile_id' and 'profile_name' form parameters in the request, respectively.

func CRTokenRequestWithCRN added in v0.8.0

func CRTokenRequestWithCRN(crToken string, profileID string, profileName string, profileCRN string, opts ...authentication.TokenOption) *authentication.TokenRequest

CRTokenRequestWithCRN builds a 'TokenRequest' struct from the user input. The value of 'crToken' is set as the value of the 'cr_token' form parameter of the request. 'profileID', 'profileName', and 'profileCRN' are optional parameters used to set the 'profile_id', 'profile_name', and 'profile_crn' form parameters in the request, respectively.

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