Add authorization framework for gRPC methods

This commit is contained in:
Theodor S. Midtlien
2026-09-08 17:20:02 +02:00
parent b2f7eacd34
commit 2df40fcc26
8 changed files with 354 additions and 159 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ type program struct {
jsonServMu sync.Mutex
serverInstance *server.Server
serverInstanceMu sync.Mutex
ruleGate *ipcauth.RuleGate
authzGate *ipcauth.AuthzGate
}
func init() {
+4 -4
View File
@@ -80,12 +80,12 @@ func (p *program) Start(svc service.Service) error {
return fmt.Errorf("parse daemon address: %w", err)
}
p.ruleGate = ipcauth.NewRuleGate()
p.authzGate = ipcauth.NewAuthzGate()
// in any case, even if configuration does not exists we run daemon to serve CLI gRPC API.
opts := append(daemonServerOptions(network),
grpc.ChainUnaryInterceptor(p.ruleGate.UnaryPolicyInterceptor()),
grpc.ChainStreamInterceptor(p.ruleGate.StreamPolicyInterceptor()),
grpc.ChainUnaryInterceptor(p.authzGate.UnaryPolicyInterceptor()),
grpc.ChainStreamInterceptor(p.authzGate.StreamPolicyInterceptor()),
)
p.serv = grpc.NewServer(opts...)
@@ -151,7 +151,7 @@ func (p *program) serve(daemonListener, jsonListener *socketListener) error {
}
serverInstance := server.New(p.ctx, util.FindFirstLogPath(logFiles), configPath, profilesDisabled, updateSettingsDisabled, captureEnabled, networksDisabled)
p.ruleGate.SetState(serverInstance)
p.authzGate.SetState(serverInstance)
if err := serverInstance.Start(); err != nil {
return fmt.Errorf("start daemon: %w", err)
}