Documentation ¶
Index ¶
- Variables
- func AccessCheckerMiddleware(ac *AccessChecker) func(c *web.C, h http.Handler) http.Handler
- func CheckAccess(token SecurityToken, attrs Attributes, res http.ResponseWriter, ...) error
- func ConfigureCors(l *goapp.Lifecycle, conf *config.Config)
- func ConfigureSecurity(l *goapp.Lifecycle, conf *config.Config)
- func EnsureRoles(roles []string, rls ...string) []string
- func RenderExpiredToken(w http.ResponseWriter)
- func RenderForbidden(w http.ResponseWriter)
- type AccessChecker
- type AccessRule
- type AffirmativeDecision
- type Attributes
- type AuthorizationChecker
- type DecisionVoter
- type DefaultAuthorizationChecker
- type DefaultSecurityToken
- type MockedDecisionVoter
- type MockedVoter
- type RoleVoter
- type SecurityToken
- type Voter
- type VoterResult
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ACCESS_GRANTED = VoterResult(1) ACCESS_ABSTAIN = VoterResult(2) ACCESS_DENIED = VoterResult(-1) ErrNotStringableAttribute = errors.New("attribute is not stringable") )
View Source
var (
ErrAccessForbidden = errors.New("access Forbidden")
)
Functions ¶
func AccessCheckerMiddleware ¶
func CheckAccess ¶
func CheckAccess(token SecurityToken, attrs Attributes, res http.ResponseWriter, req *http.Request, auth AuthorizationChecker) error
func EnsureRoles ¶
func RenderExpiredToken ¶
func RenderExpiredToken(w http.ResponseWriter)
func RenderForbidden ¶
func RenderForbidden(w http.ResponseWriter)
Types ¶
type AccessChecker ¶
type AccessChecker struct { Rules []*AccessRule DecisionVoter DecisionVoter }
func (*AccessChecker) Check ¶
func (c *AccessChecker) Check(t SecurityToken, req *http.Request) bool
type AccessRule ¶
type AccessRule struct { Path *regexp.Regexp Roles Attributes }
type AffirmativeDecision ¶
func (*AffirmativeDecision) Decide ¶
func (d *AffirmativeDecision) Decide(t SecurityToken, attrs Attributes, o interface{}) bool
func (*AffirmativeDecision) Support ¶
func (d *AffirmativeDecision) Support(o interface{}) bool
type Attributes ¶
type Attributes []interface{}
func AttributesFromString ¶
func AttributesFromString(roles []string) Attributes
func (Attributes) ToStringSlice ¶
func (attrs Attributes) ToStringSlice() ([]string, error)
type AuthorizationChecker ¶
type AuthorizationChecker interface {
IsGranted(t SecurityToken, attrs Attributes, o interface{}) (bool, error)
}
type DecisionVoter ¶
type DecisionVoter interface { Support(o interface{}) bool Decide(t SecurityToken, attrs Attributes, o interface{}) bool }
type DefaultAuthorizationChecker ¶
type DefaultAuthorizationChecker struct {
DecisionVoter DecisionVoter
}
func (*DefaultAuthorizationChecker) IsGranted ¶
func (c *DefaultAuthorizationChecker) IsGranted(t SecurityToken, attrs Attributes, o interface{}) (bool, error)
type DefaultSecurityToken ¶
Default implementation to the GuardToken
func (*DefaultSecurityToken) GetRoles ¶
func (t *DefaultSecurityToken) GetRoles() []string
func (*DefaultSecurityToken) GetUsername ¶
func (t *DefaultSecurityToken) GetUsername() string
type MockedDecisionVoter ¶
func (*MockedDecisionVoter) Decide ¶
func (m *MockedDecisionVoter) Decide(t SecurityToken, attrs Attributes, o interface{}) bool
func (*MockedDecisionVoter) Support ¶
func (m *MockedDecisionVoter) Support(o interface{}) bool
type MockedVoter ¶
func (*MockedVoter) Support ¶
func (m *MockedVoter) Support(v interface{}) bool
func (*MockedVoter) Vote ¶
func (m *MockedVoter) Vote(t SecurityToken, o interface{}, attrs Attributes) (VoterResult, error)
type RoleVoter ¶
type RoleVoter struct {
Prefix string
}
func (*RoleVoter) Vote ¶
func (v *RoleVoter) Vote(t SecurityToken, o interface{}, attrs Attributes) (result VoterResult, err error)
type SecurityToken ¶
type SecurityToken interface { // return the current username for the current token GetUsername() string // return the related roles linked to the current token GetRoles() []string }
Bare interface to used inside a request lifecycle
func GetTokenFromContext ¶
func GetTokenFromContext(c web.C) SecurityToken
type Voter ¶
type Voter interface { Support(v interface{}) bool Vote(t SecurityToken, o interface{}, attrs Attributes) (VoterResult, error) }
type VoterResult ¶
type VoterResult int
Click to show internal directories.
Click to hide internal directories.