Documentation ¶
Overview ¶
Package acl contains functions to enforce access control lists. It allows you to register multiple security policies for enforcing ACLs for users or HTTP requests. The specific policy to use must be specified from a command line argument and cannot be changed on-the-fly.
Index ¶
Constants ¶
const ( ADMIN = "admin" DEBUGGING = "debugging" MONITORING = "monitoring" )
This is a list of predefined roles. Applications are free to invent more roles, as long as the acl policies they use can understand what they mean.
Variables ¶
This section is empty.
Functions ¶
func CheckAccessActor ¶
CheckAccessActor uses the current security policy to verify if an actor has access to the role.
func CheckAccessHTTP ¶
CheckAccessHTTP uses the current security policy to verify if an actor in an http request has access to the role.
func RegisterPolicy ¶
RegisterPolicy registers a security policy. This function must be called before the first call to CheckAccess happens, preferably through an init. This will ensure that the requested policy can be found by other acl functions when needed.
func SendError ¶
func SendError(w http.ResponseWriter, err error)
SendError is a convenience function that sends an ACL error as an HTTP response.
Types ¶
type FallbackPolicy ¶
type FallbackPolicy struct{}
FallbackPolicy is the policy that's used if the requested policy cannot be found. It rejects all access.
func (FallbackPolicy) CheckAccessActor ¶
func (fp FallbackPolicy) CheckAccessActor(actor, role string) error
CheckAccessActor disallows all actor access.
func (FallbackPolicy) CheckAccessHTTP ¶
func (fp FallbackPolicy) CheckAccessHTTP(req *http.Request, role string) error
CheckAccessHTTP disallows all HTTP access.
type Policy ¶
type Policy interface { // CheckAccessActor can be called to verify if an actor // has access to the role. CheckAccessActor(actor, role string) error // CheckAccessHTTP can be called to verify if an actor in // the http request has access to the role. CheckAccessHTTP(req *http.Request, role string) error }
Policy defines the interface that needs to be satisfied by ACL policy implementors.