Documentation
¶
Overview ¶
Package darc implements Distributed Access Rights Controls.
Documentation Last Review: 08.10.2020
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is an implementation of an access service that will allow one to store and verify access for a group of identities.
- implements access.Service
func NewService ¶
NewService creates a new access service.
func (Service) Grant ¶
func (srvc Service) Grant( store store.Snapshot, cred access.Credential, idents ...access.Identity, ) error
Grant implements access.Service. It updates or creates the credential and grants the access to the group of identities.
Example (Alone) ¶
srvc := NewService(json.NewContext()) store := newStore() alice := bls.NewSigner() bob := bls.NewSigner() credential := access.NewContractCreds([]byte{1}, "example", "hello") err := srvc.Grant(store, credential, alice.GetPublicKey()) if err != nil { panic("failed to grant alice: " + err.Error()) } err = srvc.Match(store, credential, alice.GetPublicKey()) if err != nil { panic("alice has no access: " + err.Error()) } else { fmt.Println("Alice has the access") } err = srvc.Match(store, credential, bob.GetPublicKey()) if err != nil { fmt.Println("Bob has no access") }
Output: Alice has the access Bob has no access
Example (Group) ¶
srvc := NewService(json.NewContext()) store := newStore() alice := bls.NewSigner() bob := bls.NewSigner() credential := access.NewContractCreds([]byte{1}, "example", "hello") err := srvc.Grant(store, credential, alice.GetPublicKey(), bob.GetPublicKey()) if err != nil { panic("failed to grant alice: " + err.Error()) } err = srvc.Match(store, credential, alice.GetPublicKey(), bob.GetPublicKey()) if err != nil { panic("alice and bob have no access: " + err.Error()) } else { fmt.Println("[Alice, Bob] have the access") } err = srvc.Match(store, credential, alice.GetPublicKey()) if err != nil { fmt.Println("Alice alone has no access") }
Output: [Alice, Bob] have the access Alice alone has no access
func (Service) Match ¶
func (srvc Service) Match( store store.Readable, creds access.Credential, idents ...access.Identity, ) error
Match implements access.Service. It returns nil if the group of identities have access to the given credentials, otherwise a meaningful error on the reason if it does not have access.
Click to show internal directories.
Click to hide internal directories.