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

internal/middleware/authn.go   A

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 11
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A middleware.AuthFunc 0 7 3
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