per_container_roles

package
v0.0.0-...-b88682d 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: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_TOKEN_TTL_SECONDS = "21600"
View Source
const DefaultDockerNetwork = "bridge"
View Source
const DefaultLocalHostAddress = "127.0.0.1"
View Source
const DefaultPort = 9912
View Source
const EC2_METADATA_TOKEN_HEADER = "x-aws-ec2-metadata-token"
View Source
const EC2_METADATA_TOKEN_TTL_HEADER = "x-aws-ec2-metadata-token-ttl-seconds"
View Source
const REFRESHABLE_CRED_CODE = "Success"
View Source
const REFRESHABLE_CRED_TYPE = "AWS-HMAC"
View Source
const SECURITY_CREDENTIALS_RESOURCE_PATH = "/latest/meta-data/iam/security-credentials/"
View Source
const TOKEN_RESOURCE_PATH = "/latest/api/token"
View Source
const X_FORWARDED_FOR_HEADER = "X-Forwarded-For"

Variables

View Source
var RefreshTime = time.Minute * time.Duration(5)

Functions

func DenyXForwardedFor

func DenyXForwardedFor(w http.ResponseWriter, r *http.Request) bool

func GenerateCredentials

func GenerateCredentials(token string, upstreamRoleName string, roleArn string, roleSessionName string) (*stsTypes.Credentials, error)

func GetRemoteIP

func GetRemoteIP(r *http.Request) (string, error)

func GetRemoteIPFromRequest

func GetRemoteIPFromRequest(r *http.Request) (string, error)

func Serve

func Serve(port int, listenAddress string, dockerNetwork string)

func VerifyToken

func VerifyToken(w http.ResponseWriter, r *http.Request) (string, string, error)

Types

type ContainerWithCreds

type ContainerWithCreds struct {
	IPAddress       string
	RoleARN         string
	RoleName        string
	RoleSessionName string
	Creds           RefreshableCred
	Mutex           sync.Mutex
}

func (*ContainerWithCreds) UpdateCreds

func (c *ContainerWithCreds) UpdateCreds(creds RefreshableCred)

type Endpoint

type Endpoint struct {
	PortNum          int
	Server           *http.Server
	NetworkID        string
	ByContainer      map[string]*ContainerWithCreds
	ByContainerMutex sync.Mutex
}

func (*Endpoint) AddContainer

func (e *Endpoint) AddContainer(id string, role string, ip string) error

func (*Endpoint) ConfigureFromDocker

func (e *Endpoint) ConfigureFromDocker(cli *client.Client, ctx context.Context) (chan string, chan error)

func (*Endpoint) CredsByIP

func (e *Endpoint) CredsByIP(ip string) (*ContainerWithCreds, bool)

func (*Endpoint) LoadContainersFromDocker

func (e *Endpoint) LoadContainersFromDocker(cli *client.Client, ctx context.Context) error

func (*Endpoint) MonitorNetworkEvents

func (e *Endpoint) MonitorNetworkEvents(cli *client.Client, ctx context.Context)

func (*Endpoint) RemoveAllContainers

func (e *Endpoint) RemoveAllContainers()

func (*Endpoint) RemoveContainer

func (e *Endpoint) RemoveContainer(id string)

type RefreshableCred

type RefreshableCred struct {
	AccessKeyId     string
	SecretAccessKey string
	Token           string    // SessionToken
	Code            string    // REFRESHABLE_CRED_CODE
	Type            string    // REFRESHABLE_CRED_TYPE
	Expiration      time.Time // time.Parse(time.RFC3339, credentialProcessOutput.Expiration)
	LastUpdated     time.Time // time.Now()
}

func GetUpstreamCreds

func GetUpstreamCreds(token string, upstreamRoleName string) (RefreshableCred, error)

Jump to

Keyboard shortcuts

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