use requested service (#1413)
This commit is contained in:
parent
8d0826a031
commit
6efc5556e5
@ -46,7 +46,7 @@ func newService(opts ...Option) Service {
|
|||||||
options.Server.Init(
|
options.Server.Init(
|
||||||
server.WrapHandler(wrapper.HandlerStats(stats.DefaultStats)),
|
server.WrapHandler(wrapper.HandlerStats(stats.DefaultStats)),
|
||||||
server.WrapHandler(wrapper.TraceHandler(trace.DefaultTracer)),
|
server.WrapHandler(wrapper.TraceHandler(trace.DefaultTracer)),
|
||||||
server.WrapHandler(wrapper.AuthHandler(authFn, serviceName)),
|
server.WrapHandler(wrapper.AuthHandler(authFn)),
|
||||||
)
|
)
|
||||||
|
|
||||||
// set opts
|
// set opts
|
||||||
|
@ -40,9 +40,9 @@ type DeploymentSpec struct {
|
|||||||
// DeploymentCondition describes the state of deployment
|
// DeploymentCondition describes the state of deployment
|
||||||
type DeploymentCondition struct {
|
type DeploymentCondition struct {
|
||||||
LastUpdate string `json:lastUpdateTime`
|
LastUpdate string `json:lastUpdateTime`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
reason string `json:"reason,omitempty"`
|
reason string `json:"reason,omitempty"`
|
||||||
message string `json:"message,omitempty"`
|
message string `json:"message,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeploymentStatus is returned when querying deployment
|
// DeploymentStatus is returned when querying deployment
|
||||||
|
@ -152,7 +152,7 @@ func TraceHandler(t trace.Tracer) server.HandlerWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AuthHandler wraps a server handler to perform auth
|
// AuthHandler wraps a server handler to perform auth
|
||||||
func AuthHandler(fn func() auth.Auth, srvName string) server.HandlerWrapper {
|
func AuthHandler(fn func() auth.Auth) server.HandlerWrapper {
|
||||||
return func(h server.HandlerFunc) server.HandlerFunc {
|
return func(h server.HandlerFunc) server.HandlerFunc {
|
||||||
return func(ctx context.Context, req server.Request, rsp interface{}) error {
|
return func(ctx context.Context, req server.Request, rsp interface{}) error {
|
||||||
// get the auth.Auth interface
|
// get the auth.Auth interface
|
||||||
@ -187,11 +187,11 @@ func AuthHandler(fn func() auth.Auth, srvName string) server.HandlerWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify the caller has access to the resource
|
// Verify the caller has access to the resource
|
||||||
err = a.Verify(account, &auth.Resource{Type: "service", Name: srvName, Endpoint: req.Endpoint()})
|
err = a.Verify(account, &auth.Resource{Type: "service", Name: req.Service(), Endpoint: req.Endpoint()})
|
||||||
if err != nil && len(account.ID) > 0 {
|
if err != nil && len(account.ID) > 0 {
|
||||||
return errors.Forbidden("go.micro.auth", "Forbidden call made to %v:%v by %v", srvName, req.Endpoint(), account.ID)
|
return errors.Forbidden("go.micro.auth", "Forbidden call made to %v:%v by %v", req.Service(), req.Endpoint(), account.ID)
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return errors.Unauthorized("go.micro.auth", "Unauthorised call made to %v:%v", srvName, req.Endpoint())
|
return errors.Unauthorized("go.micro.auth", "Unauthorised call made to %v:%v", req.Service(), req.Endpoint())
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is an account, set it in the context
|
// There is an account, set it in the context
|
||||||
|
Loading…
Reference in New Issue
Block a user