add client ID for plugin service

This commit is contained in:
ginuerzh
2023-09-19 22:31:37 +08:00
parent 95da26cf49
commit 674a70cd23
26 changed files with 306 additions and 320 deletions

View File

@ -12,7 +12,6 @@ import (
"github.com/go-gost/core/logger"
"github.com/go-gost/x/internal/loader"
xlogger "github.com/go-gost/x/logger"
"google.golang.org/grpc"
)
type options struct {
@ -21,7 +20,6 @@ type options struct {
redisLoader loader.Loader
httpLoader loader.Loader
period time.Duration
client *grpc.ClientConn
logger logger.Logger
}
@ -57,12 +55,6 @@ func HTTPLoaderOption(httpLoader loader.Loader) Option {
}
}
func PluginConnOption(c *grpc.ClientConn) Option {
return func(opts *options) {
opts.client = c
}
}
func LoggerOption(logger logger.Logger) Option {
return func(opts *options) {
opts.logger = logger
@ -105,20 +97,20 @@ func NewAuthenticator(opts ...Option) auth.Authenticator {
}
// Authenticate checks the validity of the provided user-password pair.
func (p *authenticator) Authenticate(ctx context.Context, user, password string) bool {
func (p *authenticator) Authenticate(ctx context.Context, user, password string) (bool, string) {
if p == nil {
return true
return true, ""
}
p.mu.RLock()
defer p.mu.RUnlock()
if len(p.kvs) == 0 {
return true
return false, ""
}
v, ok := p.kvs[user]
return ok && (v == "" || password == v)
return ok && (v == "" || password == v), ""
}
func (p *authenticator) periodReload(ctx context.Context) error {