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 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 OrganizationMember
- type OrganizationRole
- type OwnerCondition
- 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) ChangeTeamName(ctx context.Context, organizationName string, teamName, newName 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) DeleteNotVerifiedUser(ctx context.Context, name string) 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) (*User, 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) GetUserEmail(ctx context.Context, user *User) (string, error)
- func (s *Store) GetUserOrganizations(ctx context.Context, name string) ([]*Organization, 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, userName string) 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) GetOwner() *Account
- 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() []byte
- func (m *User) GetTokenUsed() bool
- func (*User) ProtoMessage()
- func (m *User) Reset()
- func (m *User) String() string
- func (u *User) Validate() (err error)
Constants ¶
const ( AmpResourceName = "amprn" UserRN = AmpResourceName + ":user" OrganizationRN = AmpResourceName + ":organization" TeamRN = AmpResourceName + ":team" StackRN = AmpResourceName + ":stack" DashboardRN = AmpResourceName + ":dashboard" ObjectStoreRN = AmpResourceName + ":objectstore" CreateAction = "create" ReadAction = "read" UpdateAction = "update" DeleteAction = "delete" LeaveAction = "leave" AdminAction = "admin" AnyAction = CreateAction + "|" + ReadAction + "|" + UpdateAction + "|" + DeleteAction + "|" + LeaveAction + "|" + AdminAction )
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") ResourceAlreadyExists = Error("resource already exists") TokenAlreadyUsed = Error("token has already been used") )
Errors
const BCryptCost = 12
const DefaultOrganization = "default"
const DefaultOrganizationEmail = "default@organization.amp"
const SuperOrganization = "so"
const SuperUser = "su"
Variables ¶
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 { User string `protobuf:"bytes,1,opt,name=user" json:"user,omitempty"` Organization string `protobuf:"bytes,2,opt,name=organization" json:"organization,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) GetOrganization ¶ added in v0.12.0
func (*Account) ProtoMessage ¶
func (*Account) ProtoMessage()
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) //GetUserEmail fetches a users email GetUserEmail(ctx context.Context, user *User) (string, error) // GetUserOrganizations gets the organizations the given user is member of GetUserOrganizations(ctx context.Context, name string) (organizations []*Organization, err error) // ListUsers lists users ListUsers(ctx context.Context) (users []*User, err error) // VerifyUser verifies a user account VerifyUser(ctx context.Context, name string) (err error) // DeleteNotVerifedUser deletes a not verified user by-passing the authorization check DeleteNotVerifiedUser(ctx context.Context, name string) (err error) // DeleteUser deletes a user by name DeleteUser(ctx context.Context, name string) (*User, 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, resourceID string) (err error) // RemoveResourceFromTeam removes a resource from the given team RemoveResourceFromTeam(ctx context.Context, organizationName string, teamName string, resourceID 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) // ChangeTeamName changes the name of given team ChangeTeamName(ctx context.Context, organizationName string, teamName, newName string) (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 storage 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 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 OwnerCondition ¶ added in v0.12.0
type OwnerCondition struct { ExpectedRoles []OrganizationRole ExpectedPermissionLevels []TeamPermissionLevel }
OwnerCondition is a condition which is fulfilled if the request's subject has ownership over the resource
func (*OwnerCondition) Fulfills ¶ added in v0.12.0
func (c *OwnerCondition) Fulfills(value interface{}, r *ladon.Request) bool
Fulfills returns true if subject is granted resource access
func (*OwnerCondition) GetName ¶ added in v0.12.0
func (c *OwnerCondition) GetName() string
GetName returns the condition's name.
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) ChangeTeamName ¶ added in v0.12.0
func (s *Store) ChangeTeamName(ctx context.Context, organizationName string, teamName, newName string) (err error)
ChangeTeamName changes the name of given team
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) DeleteNotVerifiedUser ¶ added in v0.12.0
DeleteNotVerifiedUser deletes the user by name only if it's not verified
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) GetUserEmail ¶ added in v0.15.0
GetUserEmail fetches a users email
func (*Store) GetUserOrganizations ¶ added in v0.9.1
GetUserOrganizations gets the organizations the given user is member of
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"` Owner *Account `protobuf:"bytes,3,opt,name=owner" json:"owner,omitempty"` Members []string `protobuf:"bytes,4,rep,name=members" json:"members,omitempty"` Resources []*TeamResource `protobuf:"bytes,5,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 []byte `protobuf:"bytes,3,opt,name=password_hash,json=passwordHash,proto3" 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"` TokenUsed bool `protobuf:"varint,6,opt,name=token_used,json=tokenUsed" json:"token_used,omitempty"` }
func (*User) Descriptor ¶
func (*User) GetCreateDt ¶
func (*User) GetIsVerified ¶
func (*User) GetPasswordHash ¶
func (*User) GetTokenUsed ¶ added in v0.9.1
func (*User) ProtoMessage ¶
func (*User) ProtoMessage()