sts

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Host = "https://sts.aliyuncs.com/" // public domain
	Ver  = "2015-04-01"                // API version
)

API constants

Variables

This section is empty.

Functions

func AssumeRoleAPI

func AssumeRoleAPI(r *AssumeRoleParam, dur int64) aliyun.API

AssumeRoleAPI forms the API for AssumeRole. doc https://help.aliyun.com/document_detail/28763.html

func DefaultKey

func DefaultKey(p *AssumeRoleParam) string

DefaultKey concatenates the params as a key.

func GetRoleArn

func GetRoleArn(uid, roleName string) string

GetRoleArn composes the roleArn parameter; it must be of the form "acs:ram::$accountID:role/$roleName".

Types

type AssumeRoleParam

type AssumeRoleParam struct {
	RoleArn         string
	RoleSessionName string
	Policy          string
	UID             string
}

An AssumeRoleParam is the param for AssumeRole.

type AssumeRoleResponse

type AssumeRoleResponse struct {
	RequestID string          `json:"RequestId,omitempty"`
	User      AssumedRoleUser `json:"AssumedRoleUser"`
	Cred      Credentials     `json:"Credentials"`
}

An AssumeRoleResponse is the response for action AssumeRole.

type AssumedRoleUser

type AssumedRoleUser struct {
	AssumedRoleID string `json:"AssumedRoleId"`
	Arn           string `json:"Arn"`
}

An AssumedRoleUser is the user representation.

type Credentials

type Credentials struct {
	AccessKeySecret string    `json:"AccessKeySecret"`
	AccessKeyID     string    `json:"AccessKeyId"`
	Expiration      time.Time `json:"Expiration"` // "2006-01-02T15:04:05Z"
	SecurityToken   string    `json:"SecurityToken"`
}

A Credentials is the credentials obtained by AssumedRole.

type Getter

type Getter interface {
	// Get gets the credentials using the param.
	// The returned credentials should not expire before
	// specified duration (in seconds).
	Get(*AssumeRoleParam, int64) (Credentials, error)
}

A Getter gets the STS credentials.

func New

func New(s aliyun.Signer, host string) Getter

New returns a Getter for requesting credentials from host with the provided Signer. The underlying http.Client is set to have a 5s timeout.

func Wrap

func Wrap(g Getter, k KeyFunc) Getter

Wrap wraps a Getter to enable caching. If the provide keyFunc k is nil, the DefaultKey is used.

type KeyFunc

type KeyFunc func(*AssumeRoleParam) string

A KeyFunc maps the param to a key string.

Jump to

Keyboard shortcuts

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