Documentation ¶
Index ¶
- func TestHelperManagers(m Manager) func(t *testing.T)
- type Handler
- func (h *Handler) AddRoleMembers(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) CreateRole(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (h *Handler) DeleteRole(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) DeleteRoleMembers(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) FindGroupNames(w http.ResponseWriter, r *http.Request, member string, limit, offset int)
- func (h *Handler) GetRole(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (h *Handler) ListRoles(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (h *Handler) SetRoutes(r *httprouter.Router)
- func (h *Handler) UpdateRole(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- type Manager
- type MemoryManager
- func (m *MemoryManager) AddRoleMembers(role string, subjects []string) error
- func (m *MemoryManager) CreateRole(r *Role) error
- func (m *MemoryManager) DeleteRole(id string) error
- func (m *MemoryManager) FindRolesByMember(member string, limit, offset int) ([]Role, error)
- func (m *MemoryManager) GetRole(id string) (*Role, error)
- func (m *MemoryManager) ListRoles(limit, offset int) ([]Role, error)
- func (m *MemoryManager) RemoveRoleMembers(role string, subjects []string) error
- func (m *MemoryManager) UpdateRole(role Role) error
- type Role
- type SQLManager
- func (m *SQLManager) AddRoleMembers(role string, subjects []string) error
- func (m *SQLManager) CreateRole(r *Role) error
- func (m *SQLManager) CreateSchemas() (int, error)
- func (m *SQLManager) DeleteRole(id string) error
- func (m *SQLManager) FindRolesByMember(member string, limit, offset int) ([]Role, error)
- func (m *SQLManager) GetRole(id string) (*Role, error)
- func (m *SQLManager) ListRoles(limit, offset int) ([]Role, error)
- func (m *SQLManager) RemoveRoleMembers(role string, subjects []string) error
- func (m *SQLManager) UpdateRole(role Role) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestHelperManagers ¶
Types ¶
type Handler ¶
func (*Handler) AddRoleMembers ¶
func (h *Handler) AddRoleMembers(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
swagger:route POST /roles/{id}/members role addMembersToRole
Add members to a role ¶
A Role represents a group of users that share the same role and thus permissions. A role could be an administrator, a moderator, a regular user or some other sort of role.
This endpoint allows you to add members (users, applications, ...) to a specific role. You have to know the role's ID.
Consumes: - application/json Produces: - application/json Schemes: http, https Responses: 204: emptyResponse 401: genericError 403: genericError 500: genericError
func (*Handler) CreateRole ¶
func (h *Handler) CreateRole(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
swagger:route POST /roles role createRole
Create a role ¶
A Role represents a group of users that share the same role and thus permissions. A role could be an administrator, a moderator, a regular user or some other sort of role.
This endpoint allows you to create a new role. You may define members as well but you don't have to.
Consumes: - application/json Produces: - application/json Schemes: http, https Responses: 201: role 401: genericError 403: genericError 500: genericError
func (*Handler) DeleteRole ¶
func (h *Handler) DeleteRole(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
swagger:route DELETE /roles/{id} role deleteRole
Get a role by its ID ¶
A Role represents a group of users that share the same role and thus permissions. A role could be an administrator, a moderator, a regular user or some other sort of role.
This endpoint allows you to delete an existing role. You have to know the role's ID.
Consumes: - application/json Produces: - application/json Schemes: http, https Responses: 204: emptyResponse 401: genericError 403: genericError 500: genericError
func (*Handler) DeleteRoleMembers ¶
func (h *Handler) DeleteRoleMembers(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
swagger:route DELETE /roles/{id}/members role removeMembersFromRole
Remove members from a role ¶
A Role represents a group of users that share the same role and thus permissions. A role could be an administrator, a moderator, a regular user or some other sort of role.
This endpoint allows you to remove members (users, applications, ...) from a specific role. You have to know the role's ID.
Consumes: - application/json Produces: - application/json Schemes: http, https Responses: 204: emptyResponse 401: genericError 403: genericError 500: genericError
func (*Handler) FindGroupNames ¶
func (*Handler) GetRole ¶
func (h *Handler) GetRole(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
swagger:route GET /roles/{id} role getRole
Get a role by its ID ¶
A Role represents a group of users that share the same role and thus permissions. A role could be an administrator, a moderator, a regular user or some other sort of role.
This endpoint allows you to retrieve an existing role. You have to know the role's ID.
Consumes: - application/json Produces: - application/json Schemes: http, https Responses: 201: role 401: genericError 403: genericError 500: genericError
func (*Handler) ListRoles ¶
func (h *Handler) ListRoles(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
swagger:route GET /roles role listRoles
List all roles ¶
A Role represents a group of users that share the same role and thus permissions. A role could be an administrator, a moderator, a regular user or some other sort of role.
This endpoint allows you to retrieve all roles that are stored in the system.
Consumes: - application/json Produces: - application/json Schemes: http, https Responses: 200: listRolesResponse 401: genericError 403: genericError 500: genericError
func (*Handler) SetRoutes ¶
func (h *Handler) SetRoutes(r *httprouter.Router)
func (*Handler) UpdateRole ¶
func (h *Handler) UpdateRole(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
swagger:route PUT /roles/{id} role setRole
A Role represents a group of users that share the same role and thus permissions. A role could be an administrator, a moderator, a regular user or some other sort of role.
This endpoint allows you to overwrite a role. You have to know the role's ID.
Consumes: - application/json Produces: - application/json Schemes: http, https Responses: 204: emptyResponse 401: genericError 403: genericError 500: genericError
type Manager ¶
type Manager interface { CreateRole(*Role) error GetRole(id string) (*Role, error) DeleteRole(id string) error AddRoleMembers(role string, members []string) error RemoveRoleMembers(role string, members []string) error FindRolesByMember(member string, limit, offset int) ([]Role, error) ListRoles(limit, offset int) ([]Role, error) UpdateRole(role Role) error }
type MemoryManager ¶
func NewMemoryManager ¶
func NewMemoryManager() *MemoryManager
func (*MemoryManager) AddRoleMembers ¶
func (m *MemoryManager) AddRoleMembers(role string, subjects []string) error
func (*MemoryManager) CreateRole ¶
func (m *MemoryManager) CreateRole(r *Role) error
func (*MemoryManager) DeleteRole ¶
func (m *MemoryManager) DeleteRole(id string) error
func (*MemoryManager) FindRolesByMember ¶
func (m *MemoryManager) FindRolesByMember(member string, limit, offset int) ([]Role, error)
func (*MemoryManager) ListRoles ¶
func (m *MemoryManager) ListRoles(limit, offset int) ([]Role, error)
func (*MemoryManager) RemoveRoleMembers ¶
func (m *MemoryManager) RemoveRoleMembers(role string, subjects []string) error
func (*MemoryManager) UpdateRole ¶
func (m *MemoryManager) UpdateRole(role Role) error
type Role ¶
type Role struct { // ID is the role's unique id. ID string `json:"id"` // Members is who belongs to the role. Members []string `json:"members"` }
Role represents a group of users that share the same role. A role could be an administrator, a moderator, a regular user or some other sort of role.
swagger:model role
type SQLManager ¶
func NewSQLManager ¶
func NewSQLManager(db *sqlx.DB) *SQLManager
func (*SQLManager) AddRoleMembers ¶
func (m *SQLManager) AddRoleMembers(role string, subjects []string) error
func (*SQLManager) CreateRole ¶
func (m *SQLManager) CreateRole(r *Role) error
func (*SQLManager) CreateSchemas ¶
func (m *SQLManager) CreateSchemas() (int, error)
func (*SQLManager) DeleteRole ¶
func (m *SQLManager) DeleteRole(id string) error
func (*SQLManager) FindRolesByMember ¶
func (m *SQLManager) FindRolesByMember(member string, limit, offset int) ([]Role, error)
func (*SQLManager) RemoveRoleMembers ¶
func (m *SQLManager) RemoveRoleMembers(role string, subjects []string) error
func (*SQLManager) UpdateRole ¶
func (m *SQLManager) UpdateRole(role Role) error