@@ -66,7 +66,7 @@ func (proxy *NamingProxy) RegisterInstance(serviceName string, groupName string,
66
66
params ["healthy" ] = strconv .FormatBool (instance .Healthy )
67
67
params ["metadata" ] = util .ToJsonString (instance .Metadata )
68
68
params ["ephemeral" ] = strconv .FormatBool (instance .Ephemeral )
69
- return proxy .nacosServer .ReqApi (constant .SERVICE_PATH , params , http .MethodPost )
69
+ return proxy .nacosServer .ReqApi (constant .SERVICE_PATH , params , http .MethodPost , proxy . getSecurityMap () )
70
70
}
71
71
72
72
func (proxy * NamingProxy ) DeregisterInstance (serviceName string , ip string , port uint64 , clusterName string , ephemeral bool ) (string , error ) {
@@ -79,7 +79,7 @@ func (proxy *NamingProxy) DeregisterInstance(serviceName string, ip string, port
79
79
params ["ip" ] = ip
80
80
params ["port" ] = strconv .Itoa (int (port ))
81
81
params ["ephemeral" ] = strconv .FormatBool (ephemeral )
82
- return proxy .nacosServer .ReqApi (constant .SERVICE_PATH , params , http .MethodDelete )
82
+ return proxy .nacosServer .ReqApi (constant .SERVICE_PATH , params , http .MethodDelete , proxy . getSecurityMap () )
83
83
}
84
84
85
85
func (proxy * NamingProxy ) UpdateInstance (serviceName string , ip string , port uint64 , clusterName string , ephemeral bool , weight float64 , enable bool , metadata map [string ]string ) (string , error ) {
@@ -95,7 +95,7 @@ func (proxy *NamingProxy) UpdateInstance(serviceName string, ip string, port uin
95
95
params ["weight" ] = strconv .FormatFloat (weight , 'f' , - 1 , 64 )
96
96
params ["enable" ] = strconv .FormatBool (enable )
97
97
params ["metadata" ] = util .ToJsonString (metadata )
98
- return proxy .nacosServer .ReqApi (constant .SERVICE_PATH , params , http .MethodPut )
98
+ return proxy .nacosServer .ReqApi (constant .SERVICE_PATH , params , http .MethodPut , proxy . getSecurityMap () )
99
99
}
100
100
101
101
func (proxy * NamingProxy ) SendBeat (info * model.BeatInfo ) (int64 , error ) {
@@ -107,7 +107,7 @@ func (proxy *NamingProxy) SendBeat(info *model.BeatInfo) (int64, error) {
107
107
params ["serviceName" ] = info .ServiceName
108
108
params ["beat" ] = util .ToJsonString (info )
109
109
api := constant .SERVICE_BASE_PATH + "/instance/beat"
110
- result , err := proxy .nacosServer .ReqApi (api , params , http .MethodPut )
110
+ result , err := proxy .nacosServer .ReqApi (api , params , http .MethodPut , proxy . getSecurityMap () )
111
111
if err != nil {
112
112
return 0 , err
113
113
}
@@ -138,7 +138,7 @@ func (proxy *NamingProxy) GetServiceList(pageNo int, pageSize int, groupName str
138
138
}
139
139
140
140
api := constant .SERVICE_BASE_PATH + "/service/list"
141
- result , err := proxy .nacosServer .ReqApi (api , params , http .MethodGet )
141
+ result , err := proxy .nacosServer .ReqApi (api , params , http .MethodGet , proxy . getSecurityMap () )
142
142
if err != nil {
143
143
return nil , err
144
144
}
@@ -165,7 +165,7 @@ func (proxy *NamingProxy) GetServiceList(pageNo int, pageSize int, groupName str
165
165
166
166
func (proxy * NamingProxy ) ServerHealthy () bool {
167
167
api := constant .SERVICE_BASE_PATH + "/operator/metrics"
168
- result , err := proxy .nacosServer .ReqApi (api , map [string ]string {}, http .MethodGet )
168
+ result , err := proxy .nacosServer .ReqApi (api , map [string ]string {}, http .MethodGet , proxy . getSecurityMap () )
169
169
if err != nil {
170
170
logger .Errorf ("namespaceId:[%s] sending server healthy failed!,result:%s error:%+v" , proxy .clientConfig .NamespaceId , result , err )
171
171
return false
@@ -191,7 +191,7 @@ func (proxy *NamingProxy) QueryList(serviceName string, clusters string, udpPort
191
191
param ["healthyOnly" ] = strconv .FormatBool (healthyOnly )
192
192
param ["clientIP" ] = util .LocalIP ()
193
193
api := constant .SERVICE_PATH + "/list"
194
- return proxy .nacosServer .ReqApi (api , param , http .MethodGet )
194
+ return proxy .nacosServer .ReqApi (api , param , http .MethodGet , proxy . getSecurityMap () )
195
195
}
196
196
197
197
func (proxy * NamingProxy ) GetAllServiceInfoList (namespace , groupName string , pageNo , pageSize uint32 ) (string , error ) {
@@ -201,5 +201,14 @@ func (proxy *NamingProxy) GetAllServiceInfoList(namespace, groupName string, pag
201
201
param ["pageNo" ] = strconv .Itoa (int (pageNo ))
202
202
param ["pageSize" ] = strconv .Itoa (int (pageSize ))
203
203
api := constant .SERVICE_INFO_PATH + "/list"
204
- return proxy .nacosServer .ReqApi (api , param , http .MethodGet )
204
+ return proxy .nacosServer .ReqApi (api , param , http .MethodGet , proxy .getSecurityMap ())
205
+ }
206
+
207
+ func (proxy * NamingProxy ) getSecurityMap () map [string ]string {
208
+ result := make (map [string ]string , 2 )
209
+ if len (proxy .clientConfig .AccessKey ) != 0 && len (proxy .clientConfig .SecretKey ) != 0 {
210
+ result [constant .KEY_ACCESS_KEY ] = proxy .clientConfig .AccessKey
211
+ result [constant .KEY_SECRET_KEY ] = proxy .clientConfig .SecretKey
212
+ }
213
+ return result
205
214
}
0 commit comments