Documentation
¶
Overview ¶
Package accounts is a generated protocol buffer package.
It is generated from these files:
github.com/appcelerator/amp/data/accounts/accounts.proto
It has these top-level messages:
User TeamResource Team OrganizationMember Organization Account
Index ¶
- Constants
- Variables
- func CheckEmailAddress(email string) (string, error)
- func CheckID(ID string) (string, error)
- func CheckName(name string) (string, error)
- func CheckPassword(password string) (string, error)
- type Account
- type AccountType
- type Error
- type Interface
- type Organization
- func (*Organization) Descriptor() ([]byte, []int)
- func (m *Organization) GetCreateDt() int64
- func (m *Organization) GetEmail() string
- func (m *Organization) GetMembers() []*OrganizationMember
- func (m *Organization) GetName() string
- func (m *Organization) GetTeams() []*Team
- func (o *Organization) HasMember(memberName string) bool
- func (*Organization) ProtoMessage()
- func (m *Organization) Reset()
- func (m *Organization) String() string
- func (o *Organization) Validate() (err error)
- type OrganizationAccessCondition
- type OrganizationMember
- type OrganizationRole
- type Store
- func (s *Store) AddResourceToTeam(ctx context.Context, organizationName string, teamName string, ...) error
- func (s *Store) AddUserToOrganization(ctx context.Context, organizationName string, userName string) (err error)
- func (s *Store) AddUserToTeam(ctx context.Context, organizationName string, teamName string, userName string) error
- func (s *Store) ChangeOrganizationMemberRole(ctx context.Context, organizationName string, userName string, ...) (err error)
- func (s *Store) ChangeTeamResourcePermissionLevel(ctx context.Context, organizationName string, teamName string, ...) (err error)
- func (s *Store) CheckUserPassword(ctx context.Context, name string, password string) error
- func (s *Store) CreateOrganization(ctx context.Context, name string, email string) error
- func (s *Store) CreateTeam(ctx context.Context, organizationName, teamName string) error
- func (s *Store) CreateUser(ctx context.Context, name string, email string, password string) (user *User, err error)
- func (s *Store) DeleteOrganization(ctx context.Context, name string) error
- func (s *Store) DeleteTeam(ctx context.Context, organizationName string, teamName string) error
- func (s *Store) DeleteUser(ctx context.Context, name string) error
- func (s *Store) GetOrganization(ctx context.Context, name string) (organization *Organization, err error)
- func (s *Store) GetTeam(ctx context.Context, organizationName string, teamName string) (*Team, error)
- func (s *Store) GetUser(ctx context.Context, name string) (user *User, err error)
- func (s *Store) GetUserByEmail(ctx context.Context, email string) (*User, error)
- func (s *Store) IsAuthorized(ctx context.Context, owner *Account, action string, resource string, ...) bool
- func (s *Store) ListOrganizations(ctx context.Context) ([]*Organization, error)
- func (s *Store) ListTeams(ctx context.Context, organizationName string) ([]*Team, error)
- func (s *Store) ListUsers(ctx context.Context) ([]*User, error)
- func (s *Store) RemoveResourceFromTeam(ctx context.Context, organizationName string, teamName string, ...) error
- func (s *Store) RemoveUserFromOrganization(ctx context.Context, organizationName string, userName string) (err error)
- func (s *Store) RemoveUserFromTeam(ctx context.Context, organizationName string, teamName string, userName string) error
- func (s *Store) Reset(ctx context.Context)
- func (s *Store) SetUserPassword(ctx context.Context, name string, password string) error
- func (s *Store) VerifyUser(ctx context.Context, token string) (*User, error)
- type Team
- func (*Team) Descriptor() ([]byte, []int)
- func (m *Team) GetCreateDt() int64
- func (m *Team) GetMembers() []string
- func (m *Team) GetName() string
- func (m *Team) GetResources() []*TeamResource
- func (*Team) ProtoMessage()
- func (m *Team) Reset()
- func (m *Team) String() string
- func (t *Team) Validate() (err error)
- type TeamPermissionLevel
- type TeamResource
- type User
- func (*User) Descriptor() ([]byte, []int)
- func (m *User) GetCreateDt() int64
- func (m *User) GetEmail() string
- func (m *User) GetIsVerified() bool
- func (m *User) GetName() string
- func (m *User) GetPasswordHash() string
- func (*User) ProtoMessage()
- func (m *User) Reset()
- func (m *User) String() string
- func (u *User) Validate() (err error)
Constants ¶
const ( AmpResourceName = "amprn" OrganizationRN = AmpResourceName + ":organization" TeamRN = AmpResourceName + ":team" FunctionRN = AmpResourceName + ":function" StackRN = AmpResourceName + ":stack" CreateAction = "create" ReadAction = "read" UpdateAction = "update" DeleteAction = "delete" AdminAction = CreateAction + "|" + ReadAction + "|" + UpdateAction + "|" + DeleteAction )
Resources and actions
const ( InvalidName = Error("username is invalid") InvalidEmail = Error("email is invalid") PasswordTooWeak = Error("password is too weak") WrongPassword = Error("password is wrong") InvalidToken = Error("token is invalid") UserAlreadyExists = Error("user already exists") EmailAlreadyUsed = Error("email is already in use") UserNotFound = Error("user not found") UserNotVerified = Error("user not verified") OrganizationAlreadyExists = Error("organization already exists") OrganizationNotFound = Error("organization not found") TeamAlreadyExists = Error("team already exists") TeamNotFound = Error("team not found") AtLeastOneOwner = Error("organization must have at least one owner") NotAuthorized = Error("user not authorized") NotPartOfOrganization = Error("user is not part of the organization") InvalidResourceID = Error("invalid resource ID") ResourceNotFound = Error("resource not found") )
Errors
Variables ¶
var AccountType_name = map[int32]string{
0: "USER",
1: "ORGANIZATION",
}
var AccountType_value = map[string]int32{
"USER": 0,
"ORGANIZATION": 1,
}
var OrganizationRole_name = map[int32]string{
0: "ORGANIZATION_MEMBER",
1: "ORGANIZATION_OWNER",
}
var OrganizationRole_value = map[string]int32{
"ORGANIZATION_MEMBER": 0,
"ORGANIZATION_OWNER": 1,
}
var TeamPermissionLevel_name = map[int32]string{
0: "TEAM_READ",
1: "TEAM_WRITE",
2: "TEAM_ADMIN",
}
var TeamPermissionLevel_value = map[string]int32{
"TEAM_READ": 0,
"TEAM_WRITE": 1,
"TEAM_ADMIN": 2,
}
Functions ¶
func CheckEmailAddress ¶
CheckEmailAddress checks email address
func CheckPassword ¶
CheckPassword checks password
Types ¶
type Account ¶
type Account struct {
Type AccountType `protobuf:"varint,1,opt,name=type,enum=accounts.AccountType" json:"type,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
}
func GetRequesterAccount ¶
GetRequesterAccount gets the requester account from the given context, i.e. the user or organization performing the request
func (*Account) Descriptor ¶
func (*Account) GetType ¶
func (m *Account) GetType() AccountType
func (*Account) ProtoMessage ¶
func (*Account) ProtoMessage()
type AccountType ¶
type AccountType int32
const ( AccountType_USER AccountType = 0 AccountType_ORGANIZATION AccountType = 1 )
func (AccountType) EnumDescriptor ¶
func (AccountType) EnumDescriptor() ([]byte, []int)
func (AccountType) String ¶
func (x AccountType) String() string
type Interface ¶
type Interface interface {
// CreateUser creates a new user with given password
CreateUser(ctx context.Context, name string, email string, password string) (user *User, err error)
// CheckUserPassword checks the given user password
CheckUserPassword(ctx context.Context, name string, password string) (err error)
// SetUserPassword sets the given user password
SetUserPassword(ctx context.Context, name string, password string) (err error)
// GetUser fetches a user by name
GetUser(ctx context.Context, name string) (user *User, err error)
// GetUserByEmail fetches a user by email
GetUserByEmail(ctx context.Context, email string) (user *User, err error)
// ListUsers lists users
ListUsers(ctx context.Context) (users []*User, err error)
// VerifyUser verifies a user account
VerifyUser(ctx context.Context, token string) (user *User, err error)
// DeleteUser deletes a user by name
DeleteUser(ctx context.Context, name string) (err error)
// CreateOrganization creates a new organization
CreateOrganization(ctx context.Context, name string, email string) (err error)
// GetOrganization fetches a organization by name
GetOrganization(ctx context.Context, name string) (organization *Organization, err error)
// AddUserToOrganization adds a user to the given organization
AddUserToOrganization(ctx context.Context, organizationName string, userName string) (err error)
// RemoveUserFromOrganization removes a user from the given organization
RemoveUserFromOrganization(ctx context.Context, organizationName string, userName string) (err error)
// ChangeOrganizationMemberRole changes the role of given user in the given organization
ChangeOrganizationMemberRole(ctx context.Context, organizationName string, userName string, role OrganizationRole) (err error)
// ListOrganizations lists organizations
ListOrganizations(ctx context.Context) (organizations []*Organization, err error)
// DeleteOrganization deletes a organization by name
DeleteOrganization(ctx context.Context, name string) (err error)
// CreateTeam creates a new team
CreateTeam(ctx context.Context, organizationName string, teamName string) (err error)
// GetTeam fetches a team by name
GetTeam(ctx context.Context, organizationName string, teamName string) (team *Team, err error)
// ListTeams lists teams
ListTeams(ctx context.Context, organizationName string) (teams []*Team, err error)
// AddUserToTeam adds a user to the given team
AddUserToTeam(ctx context.Context, organizationName string, teamName string, userName string) (err error)
// RemoveUserFromTeam removes a user from the given team
RemoveUserFromTeam(ctx context.Context, organizationName string, teamName string, userName string) (err error)
// AddResourceToTeam adds a resource to the given team
AddResourceToTeam(ctx context.Context, organizationName string, teamName string, resourceName string) (err error)
// RemoveResourceFromTeam removes a resource from the given team
RemoveResourceFromTeam(ctx context.Context, organizationName string, teamName string, resourceName string) (err error)
// ChangeTeamResourcePermissionLevel changes the permission level over the given resource in the given team
ChangeTeamResourcePermissionLevel(ctx context.Context, organizationName string, teamName string, resource string, permissionLevel TeamPermissionLevel) (err error)
// DeleteTeam deletes a team by name
DeleteTeam(ctx context.Context, organizationName string, teamName string) (err error)
// IsAuthorized returns whether the requesting user is authorized to perform the given action on given resource
IsAuthorized(ctx context.Context, owner *Account, action string, resource string, resourceId string) bool
// Reset resets the user store
Reset(ctx context.Context)
}
Interface defines the user data access layer
type Organization ¶
type Organization struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
Email string `protobuf:"bytes,2,opt,name=email" json:"email,omitempty"`
CreateDt int64 `protobuf:"varint,3,opt,name=create_dt,json=createDt" json:"create_dt,omitempty"`
Members []*OrganizationMember `protobuf:"bytes,4,rep,name=members" json:"members,omitempty"`
Teams []*Team `protobuf:"bytes,5,rep,name=teams" json:"teams,omitempty"`
}
func (*Organization) Descriptor ¶
func (*Organization) Descriptor() ([]byte, []int)
func (*Organization) GetCreateDt ¶
func (m *Organization) GetCreateDt() int64
func (*Organization) GetEmail ¶
func (m *Organization) GetEmail() string
func (*Organization) GetMembers ¶
func (m *Organization) GetMembers() []*OrganizationMember
func (*Organization) GetName ¶
func (m *Organization) GetName() string
func (*Organization) GetTeams ¶
func (m *Organization) GetTeams() []*Team
func (*Organization) HasMember ¶
func (o *Organization) HasMember(memberName string) bool
HasMember returns whether the given user is an organization member
func (*Organization) ProtoMessage ¶
func (*Organization) ProtoMessage()
func (*Organization) Reset ¶
func (m *Organization) Reset()
func (*Organization) String ¶
func (m *Organization) String() string
func (*Organization) Validate ¶
func (o *Organization) Validate() (err error)
Validate validates Organization
type OrganizationAccessCondition ¶
type OrganizationAccessCondition struct {
ExpectedRoles []OrganizationRole
ExpectedPermissionLevels []TeamPermissionLevel
}
OrganizationAccessCondition is a condition which is fulfilled if the request's subject has the expected access in the organization (either by organization role or team access)
func (*OrganizationAccessCondition) Fulfills ¶
func (c *OrganizationAccessCondition) Fulfills(value interface{}, r *ladon.Request) bool
Fulfills returns true if subject is granted resource access
func (*OrganizationAccessCondition) GetName ¶
func (c *OrganizationAccessCondition) GetName() string
GetName returns the condition's name.
type OrganizationMember ¶
type OrganizationMember struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
Role OrganizationRole `protobuf:"varint,2,opt,name=role,enum=accounts.OrganizationRole" json:"role,omitempty"`
}
func (*OrganizationMember) Descriptor ¶
func (*OrganizationMember) Descriptor() ([]byte, []int)
func (*OrganizationMember) GetName ¶
func (m *OrganizationMember) GetName() string
func (*OrganizationMember) GetRole ¶
func (m *OrganizationMember) GetRole() OrganizationRole
func (*OrganizationMember) ProtoMessage ¶
func (*OrganizationMember) ProtoMessage()
func (*OrganizationMember) Reset ¶
func (m *OrganizationMember) Reset()
func (*OrganizationMember) String ¶
func (m *OrganizationMember) String() string
type OrganizationRole ¶
type OrganizationRole int32
const ( OrganizationRole_ORGANIZATION_MEMBER OrganizationRole = 0 OrganizationRole_ORGANIZATION_OWNER OrganizationRole = 1 )
func (OrganizationRole) EnumDescriptor ¶
func (OrganizationRole) EnumDescriptor() ([]byte, []int)
func (OrganizationRole) String ¶
func (x OrganizationRole) String() string
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements user data.Interface
func (*Store) AddResourceToTeam ¶
func (s *Store) AddResourceToTeam(ctx context.Context, organizationName string, teamName string, resourceID string) error
AddResourceToTeam adds a resource to the given team
func (*Store) AddUserToOrganization ¶
func (s *Store) AddUserToOrganization(ctx context.Context, organizationName string, userName string) (err error)
AddUserToOrganization adds a user to the given organization
func (*Store) AddUserToTeam ¶
func (s *Store) AddUserToTeam(ctx context.Context, organizationName string, teamName string, userName string) error
AddUserToTeam adds a user to the given team
func (*Store) ChangeOrganizationMemberRole ¶
func (s *Store) ChangeOrganizationMemberRole(ctx context.Context, organizationName string, userName string, role OrganizationRole) (err error)
ChangeOrganizationMemberRole changes the role of given user in the given organization
func (*Store) ChangeTeamResourcePermissionLevel ¶
func (s *Store) ChangeTeamResourcePermissionLevel(ctx context.Context, organizationName string, teamName string, resourceID string, permissionLevel TeamPermissionLevel) (err error)
ChangeTeamResourcePermissionLevel changes the permission level over the given resource in the given team
func (*Store) CheckUserPassword ¶
CheckUserPassword checks the given user password
func (*Store) CreateOrganization ¶
CreateOrganization creates a new organization
func (*Store) CreateTeam ¶
CreateTeam creates a new team
func (*Store) CreateUser ¶
func (s *Store) CreateUser(ctx context.Context, name string, email string, password string) (user *User, err error)
CreateUser creates a new user
func (*Store) DeleteOrganization ¶
DeleteOrganization deletes a organization by name
func (*Store) DeleteTeam ¶
DeleteTeam deletes a team by name
func (*Store) DeleteUser ¶
DeleteUser deletes a user by name
func (*Store) GetOrganization ¶
func (s *Store) GetOrganization(ctx context.Context, name string) (organization *Organization, err error)
GetOrganization fetches a organization by name
func (*Store) GetTeam ¶
func (s *Store) GetTeam(ctx context.Context, organizationName string, teamName string) (*Team, error)
GetTeam fetches a team by name
func (*Store) GetUserByEmail ¶
GetUserByEmail fetches a user by email
func (*Store) IsAuthorized ¶
func (s *Store) IsAuthorized(ctx context.Context, owner *Account, action string, resource string, resourceID string) bool
IsAuthorized returns whether the requesting user is authorized to perform the given action on given resource
func (*Store) ListOrganizations ¶
func (s *Store) ListOrganizations(ctx context.Context) ([]*Organization, error)
ListOrganizations lists organizations
func (*Store) RemoveResourceFromTeam ¶
func (s *Store) RemoveResourceFromTeam(ctx context.Context, organizationName string, teamName string, resourceID string) error
RemoveResourceFromTeam removes a resource from the given team
func (*Store) RemoveUserFromOrganization ¶
func (s *Store) RemoveUserFromOrganization(ctx context.Context, organizationName string, userName string) (err error)
RemoveUserFromOrganization removes a user from the given organization
func (*Store) RemoveUserFromTeam ¶
func (s *Store) RemoveUserFromTeam(ctx context.Context, organizationName string, teamName string, userName string) error
RemoveUserFromTeam removes a user from the given team
func (*Store) SetUserPassword ¶
SetUserPassword sets the given user password
type Team ¶
type Team struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
CreateDt int64 `protobuf:"varint,2,opt,name=create_dt,json=createDt" json:"create_dt,omitempty"`
Members []string `protobuf:"bytes,3,rep,name=members" json:"members,omitempty"`
Resources []*TeamResource `protobuf:"bytes,4,rep,name=resources" json:"resources,omitempty"`
}
func (*Team) Descriptor ¶
func (*Team) GetCreateDt ¶
func (*Team) GetMembers ¶
func (*Team) GetResources ¶
func (m *Team) GetResources() []*TeamResource
func (*Team) ProtoMessage ¶
func (*Team) ProtoMessage()
type TeamPermissionLevel ¶
type TeamPermissionLevel int32
const ( TeamPermissionLevel_TEAM_READ TeamPermissionLevel = 0 TeamPermissionLevel_TEAM_WRITE TeamPermissionLevel = 1 TeamPermissionLevel_TEAM_ADMIN TeamPermissionLevel = 2 )
func (TeamPermissionLevel) EnumDescriptor ¶
func (TeamPermissionLevel) EnumDescriptor() ([]byte, []int)
func (TeamPermissionLevel) String ¶
func (x TeamPermissionLevel) String() string
type TeamResource ¶
type TeamResource struct {
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
PermissionLevel TeamPermissionLevel `` /* 134-byte string literal not displayed */
}
func (*TeamResource) Descriptor ¶
func (*TeamResource) Descriptor() ([]byte, []int)
func (*TeamResource) GetId ¶
func (m *TeamResource) GetId() string
func (*TeamResource) GetPermissionLevel ¶
func (m *TeamResource) GetPermissionLevel() TeamPermissionLevel
func (*TeamResource) ProtoMessage ¶
func (*TeamResource) ProtoMessage()
func (*TeamResource) Reset ¶
func (m *TeamResource) Reset()
func (*TeamResource) String ¶
func (m *TeamResource) String() string
type User ¶
type User struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
Email string `protobuf:"bytes,2,opt,name=email" json:"email,omitempty"`
PasswordHash string `protobuf:"bytes,3,opt,name=password_hash,json=passwordHash" json:"password_hash,omitempty"`
IsVerified bool `protobuf:"varint,4,opt,name=is_verified,json=isVerified" json:"is_verified,omitempty"`
CreateDt int64 `protobuf:"varint,5,opt,name=create_dt,json=createDt" json:"create_dt,omitempty"`
}
func (*User) Descriptor ¶
func (*User) GetCreateDt ¶
func (*User) GetIsVerified ¶
func (*User) GetPasswordHash ¶
func (*User) ProtoMessage ¶
func (*User) ProtoMessage()