add metadata interceptors, auth client interceptors

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
2022-03-11 12:33:18 +01:00
parent c0e79d8834
commit 97ced73270
11 changed files with 101 additions and 68 deletions

View File

@ -2,6 +2,7 @@ package auth
import (
"context"
"crypto/subtle"
"strings"
grpc_auth "github.com/grpc-ecosystem/go-grpc-middleware/auth"
@ -40,8 +41,8 @@ func NewServerInterceptors(opts ...Option) interceptors.ServerInterceptors {
return &interceptor{o: o, authFn: ChainedAuthFuncs(o.authFns...)}
}
type interceptor struct{
o options
type interceptor struct {
o options
authFn grpc_auth.AuthFunc
}
@ -92,3 +93,7 @@ func (i *interceptor) isNotProtected(endpoint string) bool {
}
return true
}
func Equals(s1, s2 string) bool {
return subtle.ConstantTimeCompare([]byte(s1), []byte(s2)) == 1
}