fix golint issues in zrpc (#531)
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
const defaultExpiration = 5 * time.Minute
|
||||
|
||||
// An Authenticator is used to authenticate the rpc requests.
|
||||
type Authenticator struct {
|
||||
store *redis.Redis
|
||||
key string
|
||||
@@ -20,6 +21,7 @@ type Authenticator struct {
|
||||
strict bool
|
||||
}
|
||||
|
||||
// NewAuthenticator returns an Authenticator.
|
||||
func NewAuthenticator(store *redis.Redis, key string, strict bool) (*Authenticator, error) {
|
||||
cache, err := collection.NewCache(defaultExpiration)
|
||||
if err != nil {
|
||||
@@ -34,6 +36,7 @@ func NewAuthenticator(store *redis.Redis, key string, strict bool) (*Authenticat
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Authenticate authenticates the given ctx.
|
||||
func (a *Authenticator) Authenticate(ctx context.Context) error {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
|
||||
@@ -6,11 +6,13 @@ import (
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
// A Credential is used to authenticate.
|
||||
type Credential struct {
|
||||
App string
|
||||
Token string
|
||||
}
|
||||
|
||||
// GetRequestMetadata gets the request metadata.
|
||||
func (c *Credential) GetRequestMetadata(context.Context, ...string) (map[string]string, error) {
|
||||
return map[string]string{
|
||||
appKey: c.App,
|
||||
@@ -18,10 +20,12 @@ func (c *Credential) GetRequestMetadata(context.Context, ...string) (map[string]
|
||||
}, nil
|
||||
}
|
||||
|
||||
// RequireTransportSecurity always returns false.
|
||||
func (c *Credential) RequireTransportSecurity() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// ParseCredential parses credential from given ctx.
|
||||
func ParseCredential(ctx context.Context) Credential {
|
||||
var credential Credential
|
||||
|
||||
|
||||
Reference in New Issue
Block a user