-
Notifications
You must be signed in to change notification settings - Fork 109
/
api.go
49 lines (39 loc) · 1.79 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Package api implements the sentry backend API.
package api
import (
"context"
"github.com/oasisprotocol/oasis-core/go/common"
"github.com/oasisprotocol/oasis-core/go/common/accessctl"
"github.com/oasisprotocol/oasis-core/go/common/crypto/signature"
"github.com/oasisprotocol/oasis-core/go/common/grpc"
"github.com/oasisprotocol/oasis-core/go/common/grpc/policy"
"github.com/oasisprotocol/oasis-core/go/common/node"
)
// SentryAddresses contains sentry node consensus and TLS addresses.
type SentryAddresses struct {
Consensus []node.ConsensusAddress `json:"consensus"`
TLS []node.TLSAddress `json:"tls"`
}
// ServicePolicies contains policies for a GRPC service.
type ServicePolicies struct {
Service grpc.ServiceName `json:"service"`
AccessPolicies map[common.Namespace]accessctl.Policy `json:"access_policies"`
}
// Backend is a sentry backend implementation.
type Backend interface {
// Get addresses returns the list of consensus and TLS addresses of the sentry node.
GetAddresses(context.Context) (*SentryAddresses, error)
// SetUpstreamTLSPubKeys notifies the sentry node of the new TLS public keys used by its
// upstream node.
SetUpstreamTLSPubKeys(context.Context, []signature.PublicKey) error
// GetUpstreamTLSPubKeys returns the TLS public keys of the sentry node's upstream node.
GetUpstreamTLSPubKeys(context.Context) ([]signature.PublicKey, error)
// UpdatePolicies notifies the sentry node of policy changes.
UpdatePolicies(context.Context, ServicePolicies) error
}
// LocalBackend is a local sentry backend implementation.
type LocalBackend interface {
Backend
// GetPolicyChecker returns the current access policy checker for the given service.
GetPolicyChecker(context.Context, grpc.ServiceName) (*policy.DynamicRuntimePolicyChecker, error)
}