Documentation
¶
Index ¶
Constants ¶
const ( JSONMarshalError = "JSONMarshalError" JSONUnmarshalError = "JSONUnmarshalError" WriteResponseError = "WriteResponseError" InvalidQueryParameterError = "InvalidQueryParameter" InvalidLimitQueryParameterMaxExceededError = "InvalidLimitQueryParameterMaxExceeded" RoleNotFoundError = "RoleNotFoundError" GetRoleError = "GetRoleError" GetRolesError = "GetRolesError" GetPermissionBundleError = "GetPermissionBundleError" PolicyNotFoundError = "PolicyNotFoundError" PolicyAlreadyExistsError = "PolicyAlreadyExistsError" GetPolicyError = "GetPolicyError" DeletePolicyError = "DeletePolicyError" InvalidPolicyError = "InvalidPolicyError" CreateNewPolicyError = "CreateNewPolicyError" CreatePolicyWithIDError = "CreatePolicyWithIDError" UpdatePolicyError = "UpdatePolicyError" )
API error codes
const ( InternalServerErrorDescription = "internal server error" MarshalFailedDescription = "failed to marshal the request body" UnmarshalFailedDescription = "unable to unmarshal request body" ErrorMarshalFailedDescription = "failed to marshal the error" WriteResponseFailedDescription = "failed to write http response" InvalidQueryParameterDescription = "invalid query parameter" InvalidLimitQueryParameterMaxExceededDescription = "invalid query parameter: maximum exceeded" RoleNotFoundDescription = "role not found" GetRoleErrorDescription = "retrieving role from DB returned an error" GetRolesErrorDescription = "retrieving roles from DB returned an error" GetPermissionBundleErrorDescription = "failed to get permissions bundle" PolicyAlreadyExistsDescription = "policy already exists with given ID" PolicyNotFoundDescription = "policy not found" GetPolicyErrorDescription = "retrieving policy from DB returned an error" DeletePolicyErrorDescription = "deleting policy from DB returned an error" CreateNewPolicyErrorDescription = "failed to create new policy" CreatePolicyWithIDErrorDescription = "failed to create policy with given ID" UpdatePolicyErrorDescription = "failed to update policy" )
API error descriptions
const ( PoliciesRead string = "policies:read" PoliciesCreate string = "policies:create" PoliciesUpdate string = "policies:update" PoliciesDelete string = "policies:delete" OperatorStringEquals Operator = "StringEquals" OperatorStartsWith Operator = "StartsWith" )
policies permissions
const ( RolesRead string = "roles:read" RolesCreate string = "roles:create" RolesUpdate string = "roles:update" RolesDelete string = "roles:delete" )
roles permissions
Variables ¶
var ( ErrorReadingBody = errors.New("failed to read message body") ErrorParsingBody = errors.New("failed to parse json body") )
A list of errors returned from package
Functions ¶
This section is empty.
Types ¶
type Bundle ¶ added in v0.5.0
type Bundle map[string]EntityIDToPolicies
Bundle is the optimised lookup table for permissions.
type BundlePolicy ¶ added in v0.5.0
type BundlePolicy struct {
ID string `bson:"_id" json:"id,omitempty"`
Entities []string `bson:"entities" json:"-"`
Role string `bson:"role" json:"-"`
Condition Condition `bson:"condition" json:"condition,omitempty"`
}
BundlePolicy represents a policy tailored for the permissions bundle. The permissions bundle json does not include the entities and role fields.
type Condition ¶ added in v0.5.0
type Condition struct {
Attribute string `bson:"attribute" json:"attribute,omitempty"`
Operator Operator `bson:"operator" json:"operator,omitempty"`
Values []string `bson:"Values" json:"values,omitempty"`
}
Condition represents the conditions to be applied for a policy
type EntityIDToPolicies ¶ added in v0.5.0
type EntityIDToPolicies map[string][]*BundlePolicy
EntityIDToPolicies maps an entity ID to a slice of policies.
type Error ¶ added in v0.11.0
type Error struct {
Cause error `json:"-"`
Code string `json:"code"`
Description string `json:"description"`
}
Error represents an error.
type ErrorResponse ¶ added in v0.11.0
type ErrorResponse struct {
Errors []error `json:"errors"`
Status int `json:"-"`
Headers map[string]string `json:"-"`
}
ErrorResponse represents a slice of errors in a JSON response body.
func NewErrorResponse ¶ added in v0.11.0
func NewErrorResponse(statusCode int, headers map[string]string, errors ...error) *ErrorResponse
type Policy ¶ added in v0.5.0
type Policy struct {
ID string `bson:"_id" json:"id,omitempty"`
Entities []string `bson:"entities" json:"entities"`
Role string `bson:"role" json:"role"`
Condition Condition `bson:"condition" json:"condition,omitempty"`
}
Policy represent a structure for a policy in DB
type PolicyInfo ¶ added in v0.8.0
type PolicyInfo struct {
Entities []string `json:"entities"`
Role string `json:"role"`
Condition Condition `json:"condition,omitempty"`
}
PolicyInfo contains properties required to create or update a policy
func CreatePolicy ¶ added in v0.8.0
func CreatePolicy(reader io.Reader) (*PolicyInfo, error)
CreatePolicy manages the creation of a filter from reader
func (*PolicyInfo) GetPolicy ¶ added in v0.8.0
func (policy *PolicyInfo) GetPolicy(id string) *Policy
GetPolicy creates a policy object with ID
func (*PolicyInfo) ValidatePolicy ¶ added in v0.8.0
func (policy *PolicyInfo) ValidatePolicy() error
ValidatePolicy checks that all the mandatory fields are non-empty and non-empty fields contain valid values
type Role ¶
type Role struct {
ID string `bson:"_id" json:"id"`
Name string `bson:"name" json:"name"`
Permissions []string `bson:"permissions" json:"permissions"`
}
Role represents the structure for a role
type Roles ¶
type Roles struct {
Count int `json:"count"`
Offset int `json:"offset"`
Limit int `json:"limit"`
Items []Role `json:"items"`
TotalCount int `json:"total_count"`
}
Roles represents an array of the role model
type SuccessResponse ¶ added in v0.11.0
type SuccessResponse struct {
Body []byte `json:"-"`
Status int `json:"-"`
Headers map[string]string `json:"-"`
}
SuccessResponse represents a success JSON response body.
func NewSuccessResponse ¶ added in v0.11.0
func NewSuccessResponse(jsonBody []byte, statusCode int, headers map[string]string) *SuccessResponse
NewSuccessResponse creates a new SuccessResponse.
type UpdateResult ¶ added in v0.8.0
UpdateResult represent a result of the upsert policy