auth

package
v0.0.0-...-47649f3 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: BSD-3-Clause Imports: 24 Imported by: 13

Documentation

Index

Constants

View Source
const TsuruTokenEmailDomain = "tsuru-team-token"

TsuruTokenEmailDomain is the e-mail domain used to fake users from a team token. This TLD is unlikely to be used world-wide, so regular Tsuru users should not be able to register using it.

Variables

View Source
var (
	ErrInvalidToken = errors.New("Invalid token")
	ErrUserDisabled = errors.New("Disabled user")
)

Functions

func BaseTokenPermission

func BaseTokenPermission(t Token) ([]permission.Permission, error)

func ConvertOldUser

func ConvertOldUser(u *User, err error) (*authTypes.User, error)

func GroupService

func GroupService() (authTypes.GroupService, error)

func IsEmailFromTeamToken

func IsEmailFromTeamToken(email string) bool

func ParseToken

func ParseToken(header string) (string, error)

ParseToken extracts token from a header: 'type token' or 'token'

func RegisterScheme

func RegisterScheme(name string, scheme Scheme)

func RemoveRoleFromAllUsers

func RemoveRoleFromAllUsers(roleName string) error

func TeamQuotaService

func TeamQuotaService() (quotaTypes.QuotaService, error)

func TeamService

func TeamService() (authTypes.TeamService, error)

func TeamTokenService

func TeamTokenService() (authTypes.TeamTokenService, error)

func UnregisterScheme

func UnregisterScheme(name string)

func UpdateRoleFromAllUsers

func UpdateRoleFromAllUsers(roleName, newRoleName, ctx, desc string) error

func UserQuotaService

func UserQuotaService() (quotaTypes.QuotaService, error)

Types

type APIToken

type APIToken struct {
	Token     string `json:"token" bson:"apikey"`
	UserEmail string `json:"email" bson:"email"`
}

func APIAuth

func APIAuth(header string) (*APIToken, error)

func (*APIToken) Engine

func (t *APIToken) Engine() string

func (*APIToken) GetUserName

func (t *APIToken) GetUserName() string

func (*APIToken) GetValue

func (t *APIToken) GetValue() string

func (*APIToken) Permissions

func (t *APIToken) Permissions() ([]permission.Permission, error)

func (*APIToken) User

func (t *APIToken) User() (*authTypes.User, error)

type AuthenticationFailure

type AuthenticationFailure struct {
	Message string
}

func (AuthenticationFailure) Error

func (a AuthenticationFailure) Error() string

type ManagedScheme

type ManagedScheme interface {
	UserScheme
	StartPasswordReset(ctx context.Context, user *User) error
	ResetPassword(ctx context.Context, user *User, resetToken string) error
	ChangePassword(ctx context.Context, token Token, oldPassword string, newPassword string) error
}

type MultiScheme

type MultiScheme interface {
	Infos(ctx context.Context) ([]authTypes.SchemeInfo, error)
}

type Scheme

type Scheme interface {
	Auth(ctx context.Context, token string) (Token, error)
	Info(ctx context.Context) (*authTypes.SchemeInfo, error)
}

func GetScheme

func GetScheme(name string) (Scheme, error)

type Token

type Token authTypes.Token

Token type alias exists to ease refactoring while we move auth types to types/auth package. Both this type alias and the Convert*User funcs should be eliminated once we convert everyone to use authTypes.User.

type User

type User struct {
	Quota     quota.Quota
	Email     string
	Password  string
	APIKey    string
	Roles     []authTypes.RoleInstance `bson:",omitempty"`
	Groups    []string                 `bson:",omitempty"`
	FromToken bool                     `bson:",omitempty"`
	Disabled  bool                     `bson:",omitempty"`

	APIKeyLastAccess   time.Time `bson:"apikey_last_access"`
	APIKeyUsageCounter int64     `bson:"apikey_usage_counter"`
}

func ConvertNewUser

func ConvertNewUser(u *authTypes.User, err error) (*User, error)

func GetUserByEmail

func GetUserByEmail(email string) (*User, error)

func ListUsers

func ListUsers() ([]User, error)

ListUsers list all users registred in tsuru

func ListUsersWithRole

func ListUsersWithRole(role string) ([]User, error)

func ListUsersWithRolesAndContext

func ListUsersWithRolesAndContext(roles []string, context string) ([]User, error)

func (*User) AddRole

func (u *User) AddRole(roleName string, contextValue string) error

func (*User) AddRolesForEvent

func (u *User) AddRolesForEvent(roleEvent *permTypes.RoleEvent, contextValue string) error

func (*User) Create

func (u *User) Create() error

func (*User) Delete

func (u *User) Delete() error

func (*User) GetName

func (u *User) GetName() string

func (*User) Permissions

func (u *User) Permissions() ([]permission.Permission, error)

func (*User) RegenerateAPIKey

func (u *User) RegenerateAPIKey() (string, error)

func (*User) Reload

func (u *User) Reload() error

func (*User) RemoveRole

func (u *User) RemoveRole(roleName string, contextValue string) error

func (*User) ShowAPIKey

func (u *User) ShowAPIKey() (string, error)

func (*User) Update

func (u *User) Update() error

func (*User) UserGroups

func (u *User) UserGroups() ([]authTypes.Group, error)

type UserScheme

type UserScheme interface {
	Scheme

	Login(ctx context.Context, params map[string]string) (Token, error)
	Logout(ctx context.Context, token string) error
	Create(ctx context.Context, user *User) (*User, error)
	Remove(ctx context.Context, user *User) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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