Documentation
ΒΆ
Index ΒΆ
- func CheckAccess(ctx contractapi.TransactionContextInterface, rules ...Rule) error
- func HasAttribute(ctx contractapi.TransactionContextInterface, attrName string) (bool, error)
- func LogAccessDenied(ctx contractapi.TransactionContextInterface, err error)
- func New(rules ...Rule) *controller
- type AccessError
- type AlwaysDenyRule
- type AndRule
- type AnyMSPIDRule
- type AnyOURule
- type AnyRoleRule
- type AttributeRule
- type CallerInfo
- type CustomRule
- type HasAttributeRule
- type IsHLFAdmintRule
- type IsHLFClientRule
- type MSPIDRule
- type Middleware
- type NotRule
- type OURule
- type OrRule
- type RoleRule
- type Rule
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func CheckAccess ΒΆ
func CheckAccess(ctx contractapi.TransactionContextInterface, rules ...Rule) error
CheckAccess helper function for access checking
func HasAttribute ΒΆ
func HasAttribute(ctx contractapi.TransactionContextInterface, attrName string) (bool, error)
HasAttribute checks if the caller has an attribute
func LogAccessDenied ΒΆ
func LogAccessDenied(ctx contractapi.TransactionContextInterface, err error)
LogAccessDenied logs access denial Automatically determines if the error is an access denial error
Types ΒΆ
type AccessError ΒΆ
func AsAccessError ΒΆ
func AsAccessError(err error) (*AccessError, bool)
func NewAccessError ΒΆ
func NewAccessError(reason string) *AccessError
func WrapAccessError ΒΆ
func WrapAccessError(reason string, cause error) *AccessError
func (*AccessError) Error ΒΆ
func (e *AccessError) Error() string
func (*AccessError) Unwrap ΒΆ
func (e *AccessError) Unwrap() error
type AlwaysDenyRule ΒΆ
type AlwaysDenyRule struct {
// contains filtered or unexported fields
}
AlwaysDenyRule always denies access
func AlwaysDeny ΒΆ
func AlwaysDeny(message string) *AlwaysDenyRule
AlwaysDeny creates a rule that always denies access
func (*AlwaysDenyRule) Check ΒΆ
func (r *AlwaysDenyRule) Check(ctx contractapi.TransactionContextInterface) error
Check always returns an error (access denied)
type AndRule ΒΆ
type AndRule struct {
// contains filtered or unexported fields
}
AndRule combines multiple rules with AND logic (all must pass)
func (*AndRule) Check ΒΆ
func (r *AndRule) Check(ctx contractapi.TransactionContextInterface) error
Check checks all rules (all must pass)
type AnyMSPIDRule ΒΆ
type AnyMSPIDRule struct {
// contains filtered or unexported fields
}
AnyMSPIDRule checks for one of the specified MSPIDs
func RequireAnyMSPID ΒΆ
func RequireAnyMSPID(mspids ...string) *AnyMSPIDRule
RequireAnyMSPID creates a rule to check for one of the MSPIDs
func (*AnyMSPIDRule) Check ΒΆ
func (r *AnyMSPIDRule) Check(ctx contractapi.TransactionContextInterface) error
Check checks if the caller has one of the MSPIDs
type AnyOURule ΒΆ
type AnyOURule struct {
// contains filtered or unexported fields
}
AnyOURule checks for one of the specified OUs
func RequireAnyOU ΒΆ
RequireAnyOU creates a rule to check for one of the OUs
func (*AnyOURule) Check ΒΆ
func (r *AnyOURule) Check(ctx contractapi.TransactionContextInterface) error
Check checks if the caller has one of the OUs
type AnyRoleRule ΒΆ
type AnyRoleRule struct {
// contains filtered or unexported fields
}
AnyRoleRule checks for one of the specified roles
func RequireAnyRole ΒΆ
func RequireAnyRole(roles ...string) *AnyRoleRule
RequireAnyRole creates a rule to check for one of the roles
func (*AnyRoleRule) Check ΒΆ
func (r *AnyRoleRule) Check(ctx contractapi.TransactionContextInterface) error
Check checks if the caller has one of the roles
type AttributeRule ΒΆ
type AttributeRule struct {
// contains filtered or unexported fields
}
AttributeRule checks for the presence and value of an arbitrary attribute
func RequireAttribute ΒΆ
func RequireAttribute(name, value string) *AttributeRule
RequireAttribute creates a rule to check an attribute
func (*AttributeRule) Check ΒΆ
func (r *AttributeRule) Check(ctx contractapi.TransactionContextInterface) error
Check checks the attribute
type CallerInfo ΒΆ
CallerInfo contains information about the caller
func GetCallerInfo ΒΆ
func GetCallerInfo(ctx contractapi.TransactionContextInterface) (*CallerInfo, error)
GetCallerInfo gets information about the current caller
type CustomRule ΒΆ
type CustomRule struct {
// contains filtered or unexported fields
}
CustomRule allows creating custom rules using a function
func Custom ΒΆ
func Custom(name string, checkFunc func(ctx contractapi.TransactionContextInterface) error) *CustomRule
Custom creates a custom rule based on a function
func (*CustomRule) Check ΒΆ
func (r *CustomRule) Check(ctx contractapi.TransactionContextInterface) error
Check executes the custom check function
type HasAttributeRule ΒΆ
type HasAttributeRule struct {
// contains filtered or unexported fields
}
HasAttributeRule checks only for the presence of an attribute (value is not important)
func RequireHasAttribute ΒΆ
func RequireHasAttribute(name string) *HasAttributeRule
RequireHasAttribute creates a rule to check for the presence of an attribute
func (*HasAttributeRule) Check ΒΆ
func (r *HasAttributeRule) Check(ctx contractapi.TransactionContextInterface) error
Check checks for the presence of an attribute
type IsHLFAdmintRule ΒΆ
type IsHLFAdmintRule struct{}
IsHLFAdmintRule checks if the caller is an administrator in the HyperLedger Fabric network
func RequireHLFAdmin ΒΆ
func RequireHLFAdmin() *IsHLFAdmintRule
RequireHLFAdmin creates a rule to check that the caller is an administrator
func (*IsHLFAdmintRule) Check ΒΆ
func (r *IsHLFAdmintRule) Check(ctx contractapi.TransactionContextInterface) error
Check checks the caller type
type IsHLFClientRule ΒΆ
type IsHLFClientRule struct{}
IsHLFClientRule checks if the caller is a client in the HyperLedger Fabric network
func RequireHLFClient ΒΆ
func RequireHLFClient() *IsHLFClientRule
RequireHLFClient creates a rule to check that the caller is a client
func (*IsHLFClientRule) Check ΒΆ
func (r *IsHLFClientRule) Check(ctx contractapi.TransactionContextInterface) error
Check checks the caller type
type MSPIDRule ΒΆ
type MSPIDRule struct {
// contains filtered or unexported fields
}
MSPIDRule checks the caller's MSPID
func RequireMSPID ΒΆ
RequireMSPID creates a rule to check for a specific MSPID
func (*MSPIDRule) Check ΒΆ
func (r *MSPIDRule) Check(ctx contractapi.TransactionContextInterface) error
Check checks the caller's MSPID
type Middleware ΒΆ
type Middleware func(ctx contractapi.TransactionContextInterface) error
Middleware function for integration with various frameworks
func CreateMiddleware ΒΆ
func CreateMiddleware(rules ...Rule) Middleware
CreateMiddleware creates a middleware function from rules
type NotRule ΒΆ
type NotRule struct {
// contains filtered or unexported fields
}
NotRule inverts a rule
func (*NotRule) Check ΒΆ
func (r *NotRule) Check(ctx contractapi.TransactionContextInterface) error
Check inverts the result of rule checking
type OURule ΒΆ
type OURule struct {
// contains filtered or unexported fields
}
OURule checks the caller's Organizational Unit
func (*OURule) Check ΒΆ
func (r *OURule) Check(ctx contractapi.TransactionContextInterface) error
Check checks the caller's OU
type OrRule ΒΆ
type OrRule struct {
// contains filtered or unexported fields
}
OrRule combines multiple rules with OR logic (at least one must pass)
func (*OrRule) Check ΒΆ
func (r *OrRule) Check(ctx contractapi.TransactionContextInterface) error
Check checks rules (at least one must pass)
type RoleRule ΒΆ
type RoleRule struct {
// contains filtered or unexported fields
}
RoleRule checks for a specific role
func RequireRole ΒΆ
RequireRole creates a rule to check for a specific role
func (*RoleRule) Check ΒΆ
func (r *RoleRule) Check(ctx contractapi.TransactionContextInterface) error
Check checks if the caller has the role
type Rule ΒΆ
type Rule interface {
Check(ctx contractapi.TransactionContextInterface) error
}
Rule interface for access rules