auth

package
v0.0.0-...-15beef2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: BSD-3-Clause Imports: 8 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTeamName = &tsuruErrors.ValidationError{
		Message: "Invalid team name, team names should start with a letter and" +
			"contain only lower case letters, numbers, dashes and underscore",
	}
	ErrTeamAlreadyExists = errors.New("team already exists")
	ErrTeamNotFound      = errors.New("team not found")
)
View Source
var (
	ErrTeamTokenAlreadyExists           = errors.New("team token already exists")
	ErrTeamTokenNotFound                = errors.New("team token not found")
	ErrTeamTokenExpired                 = errors.New("team token expired")
	ErrCannotRemoveTeamTokenWhoOwnsApps = errors.New("cannot remove team token who owns apps")
)
View Source
var (
	ErrUserNotFound       = errors.New("user not found")
	ErrInvalidKey         = errors.New("invalid key")
	ErrKeyDisabled        = errors.New("key management is disabled")
	ErrEmailFromTeamToken = errors.New("email from team token")
)

Functions

This section is empty.

Types

type ErrTeamStillUsed

type ErrTeamStillUsed struct {
	Apps             []string
	ServiceInstances []string
}

func (*ErrTeamStillUsed) Error

func (e *ErrTeamStillUsed) Error() string

type Group

type Group struct {
	Name  string         `json:"name"`
	Roles []RoleInstance `json:"roles,omitempty"`
}

type GroupService

type GroupService interface {
	List(filter []string) ([]Group, error)
	AddRole(name, roleName, contextValue string) error
	RemoveRole(name, roleName, contextValue string) error
}

type GroupStorage

type GroupStorage interface {
	GroupService
}

type MockGroupService

type MockGroupService struct {
	OnAddRole    func(name, roleName, contextValue string) error
	OnRemoveRole func(name, roleName, contextValue string) error
	OnList       func(filter []string) ([]Group, error)
}

func (*MockGroupService) AddRole

func (m *MockGroupService) AddRole(name string, roleName, contextValue string) error

func (*MockGroupService) List

func (m *MockGroupService) List(filter []string) ([]Group, error)

func (*MockGroupService) RemoveRole

func (m *MockGroupService) RemoveRole(name, roleName, contextValue string) error

type MockTeamService

type MockTeamService struct {
	OnCreate      func(string, []string, *User) error
	OnUpdate      func(string, []string) error
	OnList        func() ([]Team, error)
	OnFindByName  func(string) (*Team, error)
	OnFindByNames func([]string) ([]Team, error)
	OnRemove      func(string) error
}

func (*MockTeamService) Create

func (m *MockTeamService) Create(ctx context.Context, teamName string, tags []string, user *User) error

func (*MockTeamService) FindByName

func (m *MockTeamService) FindByName(ctx context.Context, teamName string) (*Team, error)

func (*MockTeamService) FindByNames

func (m *MockTeamService) FindByNames(ctx context.Context, teamNames []string) ([]Team, error)

func (*MockTeamService) List

func (m *MockTeamService) List(ctx context.Context) ([]Team, error)

func (*MockTeamService) Remove

func (m *MockTeamService) Remove(ctx context.Context, teamName string) error

func (*MockTeamService) Update

func (m *MockTeamService) Update(ctx context.Context, teamName string, tags []string) error

type MockTeamStorage

type MockTeamStorage struct {
	OnInsert      func(Team) error
	OnUpdate      func(Team) error
	OnFindAll     func() ([]Team, error)
	OnFindByName  func(string) (*Team, error)
	OnFindByNames func([]string) ([]Team, error)
	OnDelete      func(Team) error
}

MockTeamStorage implements TeamStorage interface

func (*MockTeamStorage) Delete

func (m *MockTeamStorage) Delete(ctx context.Context, t Team) error

func (*MockTeamStorage) FindAll

func (m *MockTeamStorage) FindAll(ctx context.Context) ([]Team, error)

func (*MockTeamStorage) FindByName

func (m *MockTeamStorage) FindByName(ctx context.Context, name string) (*Team, error)

func (*MockTeamStorage) FindByNames

func (m *MockTeamStorage) FindByNames(ctx context.Context, names []string) ([]Team, error)

func (*MockTeamStorage) Insert

func (m *MockTeamStorage) Insert(ctx context.Context, t Team) error

func (*MockTeamStorage) Update

func (m *MockTeamStorage) Update(ctx context.Context, t Team) error

type NamedToken

type NamedToken interface {
	GetTokenName() string
}

type RoleInstance

type RoleInstance struct {
	Name         string
	ContextValue string
}

type SchemeData

type SchemeData struct {
	// OIDC fields
	ClientID string   `json:"clientID,omitempty"`
	Scopes   []string `json:"scopes,omitempty"`
	AuthURL  string   `json:"authURL,omitempty"`
	TokenURL string   `json:"tokenURL,omitempty"`
	Port     string   `json:"port,omitempty"`

	// OAuth fields
	AuthorizeURL string `json:"authorizeUrl,omitempty"`
}

type SchemeInfo

type SchemeInfo struct {
	Name    string     `json:"name"`
	Default bool       `json:"default,omitempty"`
	Data    SchemeData `json:"data"`
}

type Team

type Team struct {
	Name         string      `json:"name"`
	CreatingUser string      `json:"creatingUser"`
	Tags         []string    `json:"tags"`
	Quota        quota.Quota `json:"quota"`
}

Team represents a real world team, a team has one creating user and a name.

func (Team) GetName

func (t Team) GetName() string

type TeamService

type TeamService interface {
	Create(context.Context, string, []string, *User) error
	Update(context.Context, string, []string) error
	List(context.Context) ([]Team, error)
	FindByName(context.Context, string) (*Team, error)
	FindByNames(context.Context, []string) ([]Team, error)
	Remove(context.Context, string) error
}

type TeamStorage

type TeamStorage interface {
	Insert(context.Context, Team) error
	Update(context.Context, Team) error
	FindAll(context.Context) ([]Team, error)
	FindByName(context.Context, string) (*Team, error)
	FindByNames(context.Context, []string) ([]Team, error)
	Delete(context.Context, Team) error
}

type TeamToken

type TeamToken struct {
	Token        string         `json:"token"`
	TokenID      string         `json:"token_id"`
	Description  string         `json:"description"`
	CreatedAt    time.Time      `json:"created_at"`
	ExpiresAt    time.Time      `json:"expires_at"`
	LastAccess   time.Time      `json:"last_access"`
	CreatorEmail string         `json:"creator_email"`
	Team         string         `json:"team"`
	Roles        []RoleInstance `json:"roles,omitempty"`
}

type TeamTokenCreateArgs

type TeamTokenCreateArgs struct {
	TokenID     string `json:"token_id" form:"token_id"`
	Description string `json:"description" form:"description"`
	ExpiresIn   int    `json:"expires_in" form:"expires_in"`
	Team        string `json:"team" form:"team"`
}

type TeamTokenService

type TeamTokenService interface {
	Create(ctx context.Context, args TeamTokenCreateArgs, token Token) (TeamToken, error)
	Info(ctx context.Context, tokenID string, token Token) (TeamToken, error)
	Update(ctx context.Context, args TeamTokenUpdateArgs, token Token) (TeamToken, error)
	Delete(ctx context.Context, tokenID string) error
	Authenticate(ctx context.Context, header string) (Token, error)
	FindByTokenID(ctx context.Context, tokenID string) (TeamToken, error)
	FindByUserToken(ctx context.Context, t Token) ([]TeamToken, error)
	AddRole(ctx context.Context, tokenID string, roleName, contextValue string) error
	RemoveRole(ctx context.Context, tokenID string, roleName, contextValue string) error
}

type TeamTokenStorage

type TeamTokenStorage interface {
	Insert(context.Context, TeamToken) error
	FindByTokenID(ctx context.Context, tokenID string) (*TeamToken, error)
	FindByToken(ctx context.Context, token string) (*TeamToken, error)
	FindByTeams(ctx context.Context, teams []string) ([]TeamToken, error)
	UpdateLastAccess(ctx context.Context, token string) error
	Update(context.Context, TeamToken) error
	Delete(ctx context.Context, tokenID string) error
}

type TeamTokenUpdateArgs

type TeamTokenUpdateArgs struct {
	TokenID     string `json:"token_id" form:"token_id"`
	Regenerate  bool   `json:"regenerate" form:"regenerate"`
	Description string `json:"description" form:"description"`
	ExpiresIn   int    `json:"expires_in" form:"expires_in"`
}

type Token

type Token interface {
	GetValue() string
	GetUserName() string
	User() (*User, error)
	Engine() string
	Permissions() ([]permission.Permission, error)
}

type User

type User struct {
	Quota    quota.Quota
	Email    string
	Password string
	APIKey   string
	Roles    []RoleInstance
	Groups   []string
	// FromToken denotes whether the user was generated from team token.
	// In other words, it does not exist in the storage.
	FromToken bool
	Disabled  bool

	APIKeyLastAccess   time.Time
	APIKeyUsageCounter int64
}

Jump to

Keyboard shortcuts

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