Total Lines | 18 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package middleware |
||
2 | |||
3 | import ( |
||
4 | "context" |
||
5 | |||
6 | grpcAuth "github.com/grpc-ecosystem/go-grpc-middleware/auth" |
||
7 | |||
8 | "github.com/Permify/permify/internal/authn" |
||
9 | ) |
||
10 | |||
11 | // AuthFunc - Middleware that responsible for key authentication |
||
12 | func AuthFunc(authenticator authn.Authenticator) grpcAuth.AuthFunc { |
||
13 | return func(ctx context.Context) (context.Context, error) { |
||
14 | err := authenticator.Authenticate(ctx) |
||
15 | if err != nil { |
||
16 | return nil, err |
||
17 | } |
||
18 | return ctx, nil |
||
19 | } |
||
21 |