-
Notifications
You must be signed in to change notification settings - Fork 1
/
grpc.go
30 lines (25 loc) · 806 Bytes
/
grpc.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
package grpc
import (
"github.com/alexfalkowski/auth/client"
t "github.com/alexfalkowski/go-service/security/token"
gt "github.com/alexfalkowski/go-service/transport/grpc/security/token"
"google.golang.org/grpc"
)
// UnaryServerInterceptor for gRPC.
func UnaryServerInterceptor(cfg *t.Config, tkn *client.Token) []grpc.UnaryServerInterceptor {
if cfg.Kind != "auth" {
return nil
}
return []grpc.UnaryServerInterceptor{
gt.UnaryServerInterceptor(tkn.Verifier("jwt", "konfig", "get-config")),
}
}
// StreamServerInterceptor for gRPC.
func StreamServerInterceptor(cfg *t.Config, tkn *client.Token) []grpc.StreamServerInterceptor {
if cfg.Kind != "auth" {
return nil
}
return []grpc.StreamServerInterceptor{
gt.StreamServerInterceptor(tkn.Verifier("jwt", "konfig", "get-config")),
}
}