Passed
Push — master ( 2cecfe...2c9db6 )
by Tolga
01:26 queued 15s
created

middleware.KeyAuthFunc   A

Complexity

Conditions 3

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 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
	}
20
}
21