Fix go-micro auth wrapper init
This commit is contained in:
parent
ebb1a42d48
commit
dea2d7ab9f
@ -494,6 +494,7 @@ func (c *cmd) Before(ctx *cli.Context) error {
|
|||||||
|
|
||||||
*c.opts.Auth = a()
|
*c.opts.Auth = a()
|
||||||
clientOpts = append(clientOpts, client.Auth(*c.opts.Auth))
|
clientOpts = append(clientOpts, client.Auth(*c.opts.Auth))
|
||||||
|
serverOpts = append(serverOpts, server.Auth(*c.opts.Auth))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the profile
|
// Set the profile
|
||||||
|
@ -34,8 +34,9 @@ func newService(opts ...Option) Service {
|
|||||||
// service name
|
// service name
|
||||||
serviceName := options.Server.Options().Name
|
serviceName := options.Server.Options().Name
|
||||||
|
|
||||||
// TODO: better accessors
|
// authFn returns the auth, we pass as a function since auth
|
||||||
authFn := func() auth.Auth { return options.Auth }
|
// has not yet been set at this point.
|
||||||
|
authFn := func() auth.Auth { return options.Server.Options().Auth }
|
||||||
|
|
||||||
// wrap client to inject From-Service header on any calls
|
// wrap client to inject From-Service header on any calls
|
||||||
options.Client = wrapper.FromService(serviceName, options.Client, authFn)
|
options.Client = wrapper.FromService(serviceName, options.Client, authFn)
|
||||||
|
@ -2,7 +2,6 @@ package wrapper
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/micro/go-micro/v2/auth"
|
"github.com/micro/go-micro/v2/auth"
|
||||||
@ -179,7 +178,6 @@ func AuthHandler(fn func() auth.Auth) server.HandlerWrapper {
|
|||||||
logger.Errorf("Missing request namespace")
|
logger.Errorf("Missing request namespace")
|
||||||
namespace = auth.DefaultNamespace
|
namespace = auth.DefaultNamespace
|
||||||
}
|
}
|
||||||
fmt.Printf("Namespace is %v\n", namespace)
|
|
||||||
|
|
||||||
// Inspect the token and get the account
|
// Inspect the token and get the account
|
||||||
account, err := a.Inspect(token)
|
account, err := a.Inspect(token)
|
||||||
|
Loading…
Reference in New Issue
Block a user