Documentation
¶
Index ¶
- Constants
- func AppendToACL(ctx context.Context, projectUUID string, resourceType string, ...) error
- func AppendToUserProjects(ctx context.Context, userUUID string, projectUUID string, store stores.Store, ...) error
- func AreValidUsers(ctx context.Context, projectUUID string, users []string, store stores.Store) (bool, error)
- func Authenticate(ctx context.Context, projectUUID string, token string, store stores.Store) ([]string, string)
- func Authorize(ctx context.Context, resource string, roles []string, store stores.Store) bool
- func DeleteUserRegistration(ctx context.Context, regUUID string, str stores.Store) error
- func ExistsWithName(ctx context.Context, name string, store stores.Store) bool
- func ExistsWithUUID(ctx context.Context, uuid string, store stores.Store) bool
- func GenToken() (string, error)
- func GetNameByUUID(ctx context.Context, uuid string, store stores.Store) string
- func GetUUIDByName(ctx context.Context, name string, store stores.Store) string
- func IsAdminViewer(roles []string) bool
- func IsConsumer(roles []string) bool
- func IsProjectAdmin(roles []string) bool
- func IsPublisher(roles []string) bool
- func IsPushWorker(roles []string) bool
- func IsRoleValid(role string, validRoles []string) bool
- func IsServiceAdmin(roles []string) bool
- func ModACL(ctx context.Context, projectUUID string, resourceType string, ...) error
- func PerResource(ctx context.Context, project string, resType string, resName string, ...) bool
- func RemoveFromACL(ctx context.Context, projectUUID string, resourceType string, ...) error
- func RemoveUser(ctx context.Context, uuid string, store stores.Store) error
- func UpdateUserRegistration(ctx context.Context, regUUID, status, declineComment, modifiedBy string, ...) error
- type ACL
- type PaginatedUsers
- type ProjectRoles
- type User
- func CreateUser(ctx context.Context, uuid string, name string, fname string, lname string, ...) (User, error)
- func GetPushWorker(ctx context.Context, pwToken string, store stores.Store) (User, error)
- func GetUserByToken(ctx context.Context, token string, store stores.Store) (User, error)
- func GetUserByUUID(ctx context.Context, uuid string, store stores.Store) (User, error)
- func GetUserFromJSON(input []byte) (User, error)
- func NewUser(uuid string, projects []ProjectRoles, name string, fname string, lname string, ...) User
- func UpdateUser(ctx context.Context, ...) (User, error)
- func UpdateUserToken(ctx context.Context, uuid string, token string, store stores.Store) (User, error)
- type UserRegistration
- type UserRegistrationsList
- type Users
Constants ¶
const ( AcceptedRegistrationStatus = "accepted" PendingRegistrationStatus = "pending" DeclinedRegistrationStatus = "declined" )
Variables ¶
This section is empty.
Functions ¶
func AppendToACL ¶
func AppendToACL(ctx context.Context, projectUUID string, resourceType string, resourceName string, acl []string, store stores.Store) error
AppendToACL is used to append unique users to a topic's or sub's ACL
func AppendToUserProjects ¶
func AppendToUserProjects(ctx context.Context, userUUID string, projectUUID string, store stores.Store, pRoles ...string) error
AppendToUserProjects appends a unique project to the user's project list
func AreValidUsers ¶
func AreValidUsers(ctx context.Context, projectUUID string, users []string, store stores.Store) (bool, error)
AreValidUsers accepts a user array of usernames and checks if users exist in the store
func Authenticate ¶
func Authenticate(ctx context.Context, projectUUID string, token string, store stores.Store) ([]string, string)
Authenticate based on token
func DeleteUserRegistration ¶
DeleteUserRegistration removes the respective registration from the store based on the given uuid
func ExistsWithName ¶
ExistsWithName returns true if a user with name exists
func ExistsWithUUID ¶
ExistsWithUUID return true if a user with uuid exists
func GetNameByUUID ¶
GetNameByUUID queries user by UUID and returns the user's name. If not found, returns an empty string
func GetUUIDByName ¶
GetUUIDByName queries user by name and returns the corresponding UUID
func IsAdminViewer ¶
IsAdminViewer checks if the user is an admon viewer
func IsProjectAdmin ¶
IsProjectAdmin checks if the user is a project admin
func IsPushWorker ¶
IsPushWorker Checks if a user is a push worker
func IsRoleValid ¶
IsRoleValid checks if a role is a valid against a list of valid roles
func IsServiceAdmin ¶
IsServiceAdmin checks if the user is a service admin
func ModACL ¶
func ModACL(ctx context.Context, projectUUID string, resourceType string, resourceName string, acl []string, store stores.Store) error
ModACL is called to modify an acl
func PerResource ¶
func PerResource(ctx context.Context, project string, resType string, resName string, userUUID string, store stores.Store) bool
PerResource (for topics and subscriptions)
func RemoveFromACL ¶
func RemoveFromACL(ctx context.Context, projectUUID string, resourceType string, resourceName string, acl []string, store stores.Store) error
AppendToACL is used to remove users from a topic's or sub's acl
func RemoveUser ¶
RemoveUser removes an existing user
Types ¶
type ACL ¶
type ACL struct {
AuthUsers []string `json:"authorized_users"`
}
ACL holds the authorized users for a resource (topic/subscription)
func GetACL ¶
func GetACL(ctx context.Context, projectUUID string, resourceType string, resourceName string, store stores.Store) (ACL, error)
GetACL returns an authorized list of user for the resource (topic or subscription)
func GetACLFromJSON ¶
GetACLFromJSON retrieves ACL info from JSON
func (*ACL) ExportJSON ¶
ExportJSON export topic acl body to json for use in http response
type PaginatedUsers ¶
type PaginatedUsers struct {
Users []User `json:"users"`
NextPageToken string `json:"nextPageToken"`
TotalSize int64 `json:"totalSize"`
}
PaginatedUsers holds information about a users' page and how to access the next page
func PaginatedFindUsers ¶
func PaginatedFindUsers(ctx context.Context, pageToken string, pageSize int64, projectUUID string, privileged, detailedView bool, store stores.Store) (PaginatedUsers, error)
PaginatedFindUsers returns a page of users
func (*PaginatedUsers) ExportJSON ¶
func (pus *PaginatedUsers) ExportJSON() (string, error)
ExportJSON exports Paginated users list to json format
type ProjectRoles ¶
type ProjectRoles struct {
Project string `json:"project"`
Roles []string `json:"roles"`
Topics []string `json:"topics"`
Subs []string `json:"subscriptions"`
}
ProjectRoles is the struct that hold project and role information of the user
type User ¶
type User struct {
UUID string `json:"uuid"`
Projects []ProjectRoles `json:"projects,omitempty"`
Name string `json:"name"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
Organization string `json:"organization,omitempty"`
Description string `json:"description,omitempty"`
Token string `json:"token,omitempty"`
Email string `json:"email"`
ServiceRoles []string `json:"service_roles"`
CreatedOn string `json:"created_on,omitempty"`
ModifiedOn string `json:"modified_on,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
}
User is the struct that holds user information
func CreateUser ¶
func CreateUser(ctx context.Context, uuid string, name string, fname string, lname string, org string, desc string, projectList []ProjectRoles, token string, email string, serviceRoles []string, createdOn time.Time, createdBy string, store stores.Store) (User, error)
CreateUser creates a new user
func GetPushWorker ¶
GetPushWorker returns a push worker user by token
func GetUserByToken ¶
GetUserByToken returns a specific user by his token
func GetUserByUUID ¶
GetUserByUUID returns user information by UUID
func GetUserFromJSON ¶
GetUserFromJSON retrieves User info From JSON string
func NewUser ¶
func NewUser(uuid string, projects []ProjectRoles, name string, fname string, lname string, org string, desc string, token string, email string, serviceRoles []string, createdOn time.Time, modifiedOn time.Time, createdBy string) User
NewUser accepts parameters and creates a new user
func UpdateUser ¶
func UpdateUser(ctx context.Context, uuid, firstName, lastName, organization, description string, name string, projectList []ProjectRoles, email string, serviceRoles []string, modifiedOn time.Time, reflectObj bool, store stores.Store) (User, error)
UpdateUser updates an existing user's information IF the function caller needs to have a view on the updated user object it can set the reflectObj to true
func UpdateUserToken ¶
func UpdateUserToken(ctx context.Context, uuid string, token string, store stores.Store) (User, error)
UpdateUserToken updates an existing user's token
func (*User) ExportJSON ¶
ExportJSON exports User to json format
type UserRegistration ¶
type UserRegistration struct {
UUID string `json:"uuid"`
Name string `json:"name"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Organization string `json:"organization"`
Description string `json:"description"`
Email string `json:"email"`
Status string `json:"status"`
DeclineComment string `json:"decline_comment,omitempty"`
ActivationToken string `json:"activation_token,omitempty"`
RegisteredAt string `json:"registered_at"`
ModifiedBy string `json:"modified_by,omitempty"`
ModifiedAt string `json:"modified_at,omitempty"`
}
UserRegistration holds information about a new user registration
func FindUserRegistration ¶
func RegisterUser ¶
func RegisterUser(ctx context.Context, uuid, name, fname, lname, email, org, desc, registeredAt, atkn, status string, str stores.Store) (UserRegistration, error)
RegisterUser registers a new user to the store
type UserRegistrationsList ¶
type UserRegistrationsList struct {
UserRegistrations []UserRegistration `json:"user_registrations"`
}
UserRegistrationsList holds a list with all the user registrations in the service
func FindUserRegistrations ¶
type Users ¶
type Users struct {
List []User `json:"users,omitempty"`
}
Users holds a list of available users
func FindUsers ¶
func FindUsers(ctx context.Context, projectUUID string, uuid string, name string, priviledged bool, store stores.Store) (Users, error)
FindUsers returns a specific user or a list of all available users belonging to a project in the datastore.
func (*Users) ExportJSON ¶
ExportJSON exports Users list to json format