Documentation
¶
Index ¶
- Variables
- func GetKey(entityType string, keyPart ...string) []byte
- type Group
- type Manager
- func (store Manager) AddActionToResource(context User, resourceName string, actions ...string) (Resource, error)
- func (store Manager) AddGroup(context User, groupName string, groupDescription string) (Group, error)
- func (store Manager) AddPolicy(context User, newPolicy Policy) (Policy, error)
- func (store Manager) AddResource(context User, name, description string) (Resource, error)
- func (store Manager) AddRole(context User, roleName string, roleDescription string) (Role, error)
- func (store Manager) AddUser(context User, user User, userPassword string) (User, error)
- func (store Manager) AddUsersToGroup(context User, groupName string, users ...string) (Group, error)
- func (store Manager) AttachPoliciesToRole(context User, roleName string, policies ...string) (Role, error)
- func (store Manager) AttachPolicyToGroups(context User, policyName string, groups ...string) (Policy, error)
- func (store Manager) AttachPolicyToUsers(context User, policyName string, users ...string) (Policy, error)
- func (store Manager) AttachRoleToGroups(context User, roleName string, groups ...string) (Role, error)
- func (store Manager) AttachRoleToUsers(context User, roleName string, users ...string) (Role, error)
- func (store Manager) BeginTOTPEnrollment(userName string, expiresafter time.Duration) (TotpEnrollment, error)
- func (store Manager) Close() error
- func (store Manager) DeleteUser(context User, user User, userPassword string) (User, error)
- func (store Manager) DoPoliciesAllow(r *Request, policies map[string]Policy) error
- func (store Manager) FinishTOTPEnrollment(userName, validationCode string) (User, error)
- func (store Manager) GetAllGroups(context User) ([]Group, error)
- func (store Manager) GetAllPolicies(context User) ([]Policy, error)
- func (store Manager) GetAllResources(context User) ([]Resource, error)
- func (store Manager) GetAllRoles(context User) ([]Role, error)
- func (store Manager) GetAllUsers(context User) ([]User, error)
- func (store Manager) GetGroup(context User, groupName string) (Group, error)
- func (store Manager) GetNewToken(user User, expiresafter time.Duration) (Token, error)
- func (store Manager) GetOverview(context User) (SystemOverview, error)
- func (store Manager) GetPoliciesForUser(context User, userName string) (map[string]Policy, error)
- func (store Manager) GetPolicy(context User, policyName string) (Policy, error)
- func (store Manager) GetResource(context User, resourceName string) (Resource, error)
- func (store Manager) GetRole(context User, roleName string) (Role, error)
- func (store Manager) GetTOTPEnrollment(userName string) (TotpEnrollment, error)
- func (store Manager) GetTokenInfo(tokenID string) (Token, error)
- func (store Manager) GetUser(context User, userName string) (User, error)
- func (store Manager) GetUserForToken(tokenID string) (User, error)
- func (store Manager) GetUserWithCredentials(name, secret string) (User, error)
- func (store Manager) IsUserRequestAuthorized(user User, request *Request) bool
- func (store Manager) Search(context User, searchExpression string) (SearchResults, error)
- func (store Manager) SystemBootstrap() (User, string, error)
- type Policy
- type RegexpMatcher
- type Request
- type Resource
- type ResourceAction
- type Role
- type SearchResults
- type SystemOverview
- type Token
- type TotpEnrollment
- type User
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRequestDenied is returned when an access request can not be satisfied by any policy. ErrRequestDenied = &errorWithContext{ error: errors.New("Request was denied by default"), code: http.StatusForbidden, status: http.StatusText(http.StatusForbidden), reason: "The request was denied because no matching policy was found.", } // ErrRequestForcefullyDenied is returned when an access request is explicitly denied by a policy. ErrRequestForcefullyDenied = &errorWithContext{ error: errors.New("Request was forcefully denied"), code: http.StatusForbidden, status: http.StatusText(http.StatusForbidden), reason: "The request was denied because a policy denied request.", } // ErrNotFound is returned when a resource can not be found. ErrNotFound = &errorWithContext{ error: errors.New("Resource could not be found"), code: http.StatusNotFound, status: http.StatusText(http.StatusNotFound), } )
var DefaultMatcher = NewRegexpMatcher(512)
DefaultMatcher is the default matcher
var ( // SystemUser represents the system user SystemUser = User{Name: "System"} )
Functions ¶
Types ¶
type Group ¶
type Group struct { Name string `json:"name"` Description string `json:"description"` Created time.Time `json:"created"` CreatedBy string `json:"created_by"` Updated time.Time `json:"updated"` UpdatedBy string `json:"updated_by"` Deleted zero.Time `json:"deleted"` DeletedBy null.String `json:"deleted_by"` Users []string `json:"users"` Policies []string `json:"policies"` Roles []string `json:"roles"` }
Group represents a named collection of users
type Manager ¶
type Manager struct { Matcher matcher Input *bluemonday.Policy // contains filtered or unexported fields }
Manager is the data manager
func NewManager ¶
NewManager creates a new instance of a Manager and returns it
func (Manager) AddActionToResource ¶
func (store Manager) AddActionToResource(context User, resourceName string, actions ...string) (Resource, error)
AddActionToResource adds action(s) to a resource
func (Manager) AddGroup ¶
func (store Manager) AddGroup(context User, groupName string, groupDescription string) (Group, error)
AddGroup adds a user group to the system
func (Manager) AddResource ¶
AddResource adds a resource to the system
func (Manager) AddUsersToGroup ¶
func (store Manager) AddUsersToGroup(context User, groupName string, users ...string) (Group, error)
AddUsersToGroup adds user(s) to a group -- and tracks that relationship at the group level and at the user level
func (Manager) AttachPoliciesToRole ¶
func (store Manager) AttachPoliciesToRole(context User, roleName string, policies ...string) (Role, error)
AttachPoliciesToRole attaches policies to a role -- and tracks that relationship at the role level and at the policy level
func (Manager) AttachPolicyToGroups ¶
func (store Manager) AttachPolicyToGroups(context User, policyName string, groups ...string) (Policy, error)
AttachPolicyToGroups attaches a policy to the given group(s)
func (Manager) AttachPolicyToUsers ¶
func (store Manager) AttachPolicyToUsers(context User, policyName string, users ...string) (Policy, error)
AttachPolicyToUsers attaches a policy to the given user(s)
func (Manager) AttachRoleToGroups ¶
func (store Manager) AttachRoleToGroups(context User, roleName string, groups ...string) (Role, error)
AttachRoleToGroups attaches a role to the given group(s)
func (Manager) AttachRoleToUsers ¶
func (store Manager) AttachRoleToUsers(context User, roleName string, users ...string) (Role, error)
AttachRoleToUsers attaches a role to the given user(s)
func (Manager) BeginTOTPEnrollment ¶
func (store Manager) BeginTOTPEnrollment(userName string, expiresafter time.Duration) (TotpEnrollment, error)
BeginTOTPEnrollment begins TOTP enrollment for a user. If the user already has two factor authentication enabled, this will return an error
func (Manager) DeleteUser ¶
DeleteUser adds a user to the system
func (Manager) DoPoliciesAllow ¶
DoPoliciesAllow checks to see if the request is allowed by policy
func (Manager) FinishTOTPEnrollment ¶
FinishTOTPEnrollment finishes TOTP enrollment for a user. If the user already has two factor authentication enabled, this will return an error
func (Manager) GetAllGroups ¶
GetAllGroups gets all groups in the system
func (Manager) GetAllPolicies ¶
GetAllPolicies gets all policies in the system
func (Manager) GetAllResources ¶
GetAllResources gets all resources in the system
func (Manager) GetAllRoles ¶
GetAllRoles gets all roles in the system
func (Manager) GetAllUsers ¶
GetAllUsers gets all users in the system
func (Manager) GetNewToken ¶
GetNewToken gets a token for the given user. The token will have a TTL and expire automatically
func (Manager) GetOverview ¶
func (store Manager) GetOverview(context User) (SystemOverview, error)
GetOverview gets a system overview of counts in the system
func (Manager) GetPoliciesForUser ¶
GetPoliciesForUser gets policies for a user. Chains include: User -> Policies User -> Role -> Policies User -> Group -> Policies User -> Group -> Role -> Policies
func (Manager) GetResource ¶
GetResource gets a resource from the system
func (Manager) GetTOTPEnrollment ¶
func (store Manager) GetTOTPEnrollment(userName string) (TotpEnrollment, error)
GetTOTPEnrollment gets the TOTP enrollment for a user. If the enrollment information can't be found, this will return an error
func (Manager) GetTokenInfo ¶
GetTokenInfo returns token information for a given unexpired tokenID (or an error if it can't be found)
func (Manager) GetUserForToken ¶
GetUserForToken returns user information for a given unexpired tokenID (or an error if token or user can't be found)
func (Manager) GetUserWithCredentials ¶
GetUserWithCredentials gets a user given a set of credentials
func (Manager) IsUserRequestAuthorized ¶
IsUserRequestAuthorized determines whether the given user is authorized to execute the given request
type Policy ¶
type Policy struct { Name string `json:"sid"` Effect string `json:"effect"` Resources []string `json:"resources"` Actions []string `json:"actions"` Roles []string `json:"roles"` Users []string `json:"users"` Groups []string `json:"groups"` Created time.Time `json:"created"` CreatedBy string `json:"created_by"` Updated time.Time `json:"updated"` UpdatedBy string `json:"updated_by"` Deleted zero.Time `json:"deleted"` DeletedBy null.String `json:"deleted_by"` }
Policy is an AWS style policy document. They wrap up the following ideas: - Resources: The things in a system that users would need permissions to - Actions: The interactions users have with those resources - Effect: The permissive effect of a policy (allow or deny) - Conditions: Additional information to take into account when evaluating a policy Policies can be attached to a user or user group. They can also be grouped in a role
type RegexpMatcher ¶
RegexpMatcher represents a regular expression matcher
func NewRegexpMatcher ¶
func NewRegexpMatcher(size int) *RegexpMatcher
NewRegexpMatcher creates and returns a new RegexpMatcher
type Resource ¶
type Resource struct { Name string `json:"name"` Description string `json:"description"` Created time.Time `json:"created"` CreatedBy string `json:"created_by"` Updated time.Time `json:"updated"` UpdatedBy string `json:"updated_by"` Deleted zero.Time `json:"deleted"` DeletedBy null.String `json:"deleted_by"` Actions []string `json:"actions"` }
Resource represents a thing that can be acted on. This is really only used for lookups when editing a policy. Because a policy can have wildcards, this type isn't used for policy validation.
type ResourceAction ¶
ResourceAction represents an action that can be performed in relation to the parent resource. Example: list, get, update
type Role ¶
type Role struct { Name string `json:"name"` Description string `json:"description"` Created time.Time `json:"created"` CreatedBy string `json:"created_by"` Updated time.Time `json:"updated"` UpdatedBy string `json:"updated_by"` Deleted zero.Time `json:"deleted"` DeletedBy null.String `json:"deleted_by"` Policies []string `json:"policies"` Users []string `json:"users"` Groups []string `json:"groups"` }
Role represents a named collection of policies. Roles can be attached to a user or a user group
type SearchResults ¶
type SearchResults struct { Users []string Groups []string Roles []string Policies []string Resources []string }
SearchResults represents search results
type SystemOverview ¶
type SystemOverview struct { UserCount int GroupCount int RoleCount int PolicyCount int ResourceCount int }
SystemOverview represents the system overview data
type Token ¶
type Token struct { ID string `json:"token"` User string `json:"user"` Created time.Time `json:"created"` Expires time.Time `json:"expires"` }
Token represents an auth token
type TotpEnrollment ¶
type TotpEnrollment struct { User string `json:"user"` Secret string `json:"secret"` Image string `json:"image"` URL string `json:"url"` }
TotpEnrollment represents an enrollment record for Time based one-time-pad (two factor authentication) for a user Both the secret and the image will be stored temporarily until the user validates the key with a generated password (indicating they have setup the TOTP key in their app and have generated a valid code at least once). When enrollment is complete, this record will be removed and the secret will be stored with the user data
func (TotpEnrollment) GetImage ¶
func (enrollment TotpEnrollment) GetImage() ([]byte, error)
GetImage gets the image for an enrollment.
type User ¶
type User struct { Name string `json:"name"` Enabled bool `json:"enabled"` Description string `json:"description"` SecretHash string `json:"secrethash"` TOTPEnabled bool `json:"totpenabled"` TOTPSecret string `json:"totpsecret"` Created time.Time `json:"created"` CreatedBy string `json:"created_by"` Updated time.Time `json:"updated"` UpdatedBy string `json:"updated_by"` Deleted zero.Time `json:"deleted"` DeletedBy null.String `json:"deleted_by"` Groups []string `json:"groups"` Policies []string `json:"policies"` Roles []string `json:"roles"` }
User represents a user in the system. Users are associated with resources and roles within those applications/resources/services. They can be created/updated/deleted. If they are deleted, eventually they will be removed from the system. The admin user can only be disabled, not deleted