MSP-1069 update proxy grpc http
This commit is contained in:
1 parent
614abce93f
commit
b054257e06
3 files changed
+15
-10
No files matched your search
@@ -0,0 +1,5 @@
|
||||
package proxy
|
||||
|
||||
const (
|
||||
xAdminIdHeader = "x-admin-id"
|
||||
)
|
||||
+4
-7
@@ -7,6 +7,9 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
|
||||
"github.com/integration-system/isp-kit/grpc"
|
||||
"github.com/integration-system/isp-kit/grpc/client"
|
||||
"github.com/integration-system/isp-kit/grpc/isp"
|
||||
@@ -17,12 +20,6 @@ import (
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
const (
|
||||
adminAuthHeader = "x-auth-admin"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -84,7 +81,7 @@ func (p Grpc) Handle(ctx *request.Context) error {
|
||||
md[grpc.ServiceIdHeader] = []string{strconv.Itoa(authData.ServiceId)}
|
||||
md[grpc.ApplicationIdHeader] = []string{strconv.Itoa(authData.ApplicationId)}
|
||||
if ctx.IsAdminAuthenticated() {
|
||||
md[adminAuthHeader] = []string{ctx.AdminToken()}
|
||||
md[xAdminIdHeader] = []string{strconv.Itoa(ctx.AdminId())}
|
||||
}
|
||||
}
|
||||
requestContext := metadata.NewOutgoingContext(ctx.Context(), md)
|
||||
|
||||
+6
-3
@@ -8,12 +8,13 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
|
||||
"github.com/integration-system/isp-kit/grpc"
|
||||
"github.com/integration-system/isp-kit/requestid"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
type HttpHostManager interface {
|
||||
@@ -59,7 +60,9 @@ func (p Http) Handle(ctx *request.Context) error {
|
||||
request.Header.Set(grpc.ServiceIdHeader, strconv.Itoa(authData.ServiceId))
|
||||
request.Header.Set(grpc.ApplicationIdHeader, strconv.Itoa(authData.ApplicationId))
|
||||
if ctx.IsAdminAuthenticated() {
|
||||
request.Header.Set(adminAuthHeader, ctx.AdminToken())
|
||||
request.Header.Set(xAdminIdHeader, strconv.Itoa(ctx.AdminId()))
|
||||
} else {
|
||||
request.Header.Del(xAdminIdHeader)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user