server

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigFileHandler

type ConfigFileHandler interface {
	Read() (map[string]core.Config, error)
	Write(map[string]core.Config) error
}

ConfigFileHandler is the manager read and write a config file.

type CredFileHandler

type CredFileHandler interface {
	Read() (map[string]core.Cred, error)
	Write(map[string]core.Cred) error
	Remove() error
	GetFilePath() string
}

CredFileHandler is the manager read and write a credential file.

type FileWatcher

type FileWatcher interface {
	Watch(context.Context, chan<- fsnotify.Event)
}

FileWatcher send a event when the file has a operation.

type Interactor

type Interactor struct {
	// contains filtered or unexported fields
}

Interactor manage the credential file and the config file.

func NewInteractor

func NewInteractor(origCredPath, credPath, confPath string) *Interactor

NewInteractor create a new interactor.

func (*Interactor) Gen

func (i *Interactor) Gen(profile, token string) error

Gen generate the secure token from STS.

func (*Interactor) GetConfig

func (i *Interactor) GetConfig(profile string) (core.Config, bool, error)

GetConfig get the config of profile.

func (*Interactor) GetCredentialFile added in v0.2.0

func (i *Interactor) GetCredentialFile() string

GetCredentialFile return the path of awscred credentials.

func (*Interactor) GetCredentialProfile added in v0.2.0

func (i *Interactor) GetCredentialProfile(profile string) core.Cred

GetCredentialProfile returns the credential of profile.

func (*Interactor) GetOriginalCred

func (i *Interactor) GetOriginalCred(profile string) (core.Cred, bool, error)

GetOriginalCred get the credential of profile.

func (*Interactor) GetProfileList

func (i *Interactor) GetProfileList() ([]ProfileInfo, error)

GetProfileList return profiles.

func (*Interactor) Off

func (i *Interactor) Off(profile string) error

Off set the profile disabled.

func (*Interactor) On

func (i *Interactor) On(profile string) error

On set the profile enabled, and if the configuration doesn't exist it create a new configuration.

func (*Interactor) Reflect

func (i *Interactor) Reflect() error

Reflect reflect the original credential file, only for enabled profiles.

func (*Interactor) SetConfig

func (i *Interactor) SetConfig(profile string, conf core.Config) error

SetConfig set the config of profile.

func (*Interactor) SetCred

func (i *Interactor) SetCred(profile string, cred core.Cred) error

SetCred set a new credential for the profile.

func (*Interactor) StartWatch

func (i *Interactor) StartWatch(ctx context.Context)

StartWatch start to watch the orignal credential file and reflect changes into the credential file.

func (*Interactor) Terminate

func (i *Interactor) Terminate() error

Terminate stop to watch the original credential file and remove the reflected credential file.

type ProfileInfo

type ProfileInfo struct {
	Name     string
	On       bool
	Serial   string
	Duration int64
	Expired  string
}

ProfileInfo is the information of profile.

type Server

type Server struct {
	pb.UnimplementedAWSCredServer
	Inter *Interactor
	// contains filtered or unexported fields
}

Server interact with the client to manage and reflect the credentials file.

func NewServer

func NewServer(i *Interactor) *Server

NewServer create a new server.

func (*Server) GetCredentialsFile added in v0.2.0

GetCredentialsFile return the path of file.

func (*Server) GetCredentialsProfile added in v0.2.0

GetCredentialsProfile return the credentials of profile.

func (*Server) GetProfileList

func (s *Server) GetProfileList(ctx context.Context, in *pb.GetProfileListRequest) (*pb.GetProfileListResponse, error)

GetProfileList return the information of profiles.

func (*Server) SetConfig

func (s *Server) SetConfig(ctx context.Context, in *pb.SetConfigRequest) (*pb.SetConfigResponse, error)

SetConfig set the configuration of the profile.

func (*Server) SetGenerate

func (s *Server) SetGenerate(ctx context.Context, in *pb.SetGenerateRequest) (*pb.SetGenerateResponse, error)

SetGenerate generate the session token of the profile, and reflect it on the credential file.

func (*Server) SetOff

func (s *Server) SetOff(ctx context.Context, in *pb.SetOffRequest) (*pb.SetOffResponse, error)

SetOff set the profile disabled.

func (*Server) SetOn

func (s *Server) SetOn(ctx context.Context, in *pb.SetOnRequest) (*pb.SetOnResponse, error)

SetOn set the profile enabled. It makes to reflect the session token on the credential file.

type SessionTokenGenerator

type SessionTokenGenerator interface {
	Generate(core.Cred, core.Config, string) (core.SessionToken, error)
}

SessionTokenGenerator generate the secure cred.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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