Skip to content

Commit

Permalink
[ISSUE #1077] fix:http 客户端接口鉴权行为保持和gRPC一致 (#1076)
Browse files Browse the repository at this point in the history
* fix issue #629 (#693)

* docs:优化错误信息描述

* Update zh.toml

* fix:修复eureka心跳协议错误码不兼容问题

* fix:修复eureka心跳协议错误码不兼容问题

* unit:添加单元测试

* test:调整测试配置文件位置

* fix:issue #692

* fix:issue #692

* fix:issue #692

* fix:issue #692

* docs:add error code desc

* fix:调整license-checker的触发

* fix:调整license-checker的触发

* fix:http 客户端接口鉴权凭据获取
  • Loading branch information
chuntaojun committed Apr 11, 2023
1 parent ea61d50 commit dad9aac
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion apiserver/httpserver/v1/naming_client_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package v1

import (
"context"
"fmt"

"github.com/emicklei/go-restful/v3"
Expand Down Expand Up @@ -109,6 +110,10 @@ func (h *HTTPServerV1) RegisterInstance(req *restful.Request, rsp *restful.Respo
handler.WriteHeaderAndProto(api.NewResponseWithMsg(apimodel.Code_ParseException, err.Error()))
return
}
// 客户端请求中带了 token 的,优先已请求中的为准
if instance.GetServiceToken().GetValue() != "" {
ctx = context.WithValue(ctx, utils.ContextAuthTokenKey, instance.GetServiceToken().GetValue())
}

handler.WriteHeaderAndProto(h.namingServer.RegisterInstance(ctx, instance))
}
Expand All @@ -126,7 +131,10 @@ func (h *HTTPServerV1) DeregisterInstance(req *restful.Request, rsp *restful.Res
handler.WriteHeaderAndProto(api.NewResponseWithMsg(apimodel.Code_ParseException, err.Error()))
return
}

// 客户端请求中带了 token 的,优先已请求中的为准
if instance.GetServiceToken().GetValue() != "" {
ctx = context.WithValue(ctx, utils.ContextAuthTokenKey, instance.GetServiceToken().GetValue())
}
handler.WriteHeaderAndProto(h.namingServer.DeregisterInstance(ctx, instance))
}

Expand Down

0 comments on commit dad9aac

Please sign in to comment.