Documentation ¶
Index ¶
- type Service
- func (f *Service) AddResourcePermission(user, resource string, action per.Action) (bool, *gz.ErrMsg)
- func (f *Service) AddScore(groupID *string, competition *string, circuit *string, owner *string, ...) *gz.ErrMsg
- func (f *Service) CanPerformWithRole(owner *string, user string, role per.Role) (bool, *gz.ErrMsg)
- func (f *Service) GetOrganization(username string) (*users.Organization, *gz.ErrMsg)
- func (f *Service) GetUserFromUsername(username string) (*users.User, *gz.ErrMsg)
- func (f *Service) IsAuthorizedForResource(user, resource string, action per.Action) (bool, *gz.ErrMsg)
- func (f *Service) IsSystemAdmin(user string) bool
- func (f *Service) QueryForResourceVisibility(q *gorm.DB, owner *string, user *users.User) *gorm.DB
- func (f *Service) StartAutoLoadPolicy()
- func (f *Service) UserFromJWT(r *http.Request) (*users.User, bool, *gz.ErrMsg)
- func (f *Service) VerifyOwner(owner, user string, p per.Action) (bool, *gz.ErrMsg)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
Service is a fake users.Service implementation.
func NewFakeService ¶
func NewFakeService() *Service
NewFakeService initializes a new fake user service implementation. This provider uses the mock library
func (*Service) AddResourcePermission ¶
func (f *Service) AddResourcePermission(user, resource string, action per.Action) (bool, *gz.ErrMsg)
AddResourcePermission adds a user (or group) permission on a resource
func (*Service) AddScore ¶
func (f *Service) AddScore(groupID *string, competition *string, circuit *string, owner *string, score *float64, sources *string) *gz.ErrMsg
AddScore creates a score entry for a simulation.
func (*Service) CanPerformWithRole ¶
CanPerformWithRole checks if the 'owner' arg is an organization or a user. If the 'owner' is an organization, it verifies that the given 'user' arg is authorized to act as the given Role (or above) in the organization. If the 'owner' is a user, it verifies that the 'user' arg is the same as the owner. As a third alternative, if 'owner' is nil then it checks if the 'user' is part of the System Admins.
func (*Service) GetOrganization ¶
func (f *Service) GetOrganization(username string) (*users.Organization, *gz.ErrMsg)
GetOrganization gets a user's organization database entry from the username
func (*Service) GetUserFromUsername ¶
GetUserFromUsername returns the user database entry from the username
func (*Service) IsAuthorizedForResource ¶
func (f *Service) IsAuthorizedForResource(user, resource string, action per.Action) (bool, *gz.ErrMsg)
IsAuthorizedForResource checks if user has the permission to perform an action on a resource.
func (*Service) IsSystemAdmin ¶
IsSystemAdmin returns a bool indicating if the given user is a system admin.
func (*Service) QueryForResourceVisibility ¶
QueryForResourceVisibility checks the relationship between requestor (user) and the resource owner to formulate a database query to determine whether a resource is visible to the user
func (*Service) StartAutoLoadPolicy ¶
func (f *Service) StartAutoLoadPolicy()
StartAutoLoadPolicy starts the auto load remote policy
func (*Service) UserFromJWT ¶
UserFromJWT returns the User associated to the http request's JWT token. This function can return ErrorAuthJWTInvalid if the token cannot be read, or ErrorAuthNoUser no user with such identity exists in the DB.
func (*Service) VerifyOwner ¶
VerifyOwner checks if the 'owner' arg is an organization or a user. If the 'owner' is an organization, it verifies that the given 'user' arg has the expected permission in the organization. If the 'owner' is a user, it verifies that the 'user' arg is the same as the owner. Dev note: this is an alternative implementation of ign-fuelserver UserService's VerifyOwner.