@@ -36,10 +36,10 @@ nacos-sdk = { version = "0.4", features = ["default"] }
36
36
// Attention! "public" is "", it is recommended to customize the namespace with clear meaning.
37
37
. namespace ("" )
38
38
. app_name (" simple_app" ),
39
- // .auth_username("TODO ")
40
- // .auth_password("TODO ")
39
+ . auth_username (" username " )
40
+ . auth_password (" password " )
41
41
)
42
- // .enable_auth_plugin_http()
42
+ . enable_auth_plugin_http ()
43
43
. build ()? ;
44
44
45
45
// example get a config
@@ -79,10 +79,10 @@ nacos-sdk = { version = "0.4", features = ["default"] }
79
79
// Attention! "public" is "", it is recommended to customize the namespace with clear meaning.
80
80
. namespace ("" )
81
81
. app_name (" simple_app" ),
82
- // .auth_username("TODO ")
83
- // .auth_password("TODO ")
82
+ . auth_username (" username " )
83
+ . auth_password (" password " )
84
84
)
85
- // .enable_auth_plugin_http()
85
+ . enable_auth_plugin_http ()
86
86
. build ()? ;
87
87
88
88
pub struct ExampleInstanceChangeListener ;
@@ -121,6 +121,65 @@ See them in `nacos_sdk::api::props::ClientProps` or `nacos_sdk::api::constants::
121
121
e.g.
122
122
- env ` NACOS_CLIENT_COMMON_THREAD_CORES ` to set nacos-client-thread-pool num, default 1
123
123
- env ` NACOS_CLIENT_NAMING_PUSH_EMPTY_PROTECTION ` for naming empty data notify protection, default true
124
+ - env ` NACOS_CLIENT_USERNAME ` to set http auth username
125
+ - env ` NACOS_CLIENT_PASSWORD ` to set http auth password
126
+ - env ` NACOS_CLIENT_ACCESS_KEY ` to set Aliyun ram access-key
127
+ - env ` NACOS_CLIENT_SECRET_KEY ` to set Aliyun ram access-secret
128
+
129
+ ### AuthPlugin Features
130
+ - > Set access-key, access-secret via Environment variables are recommended.
131
+ - auth-by-http
132
+ - support http auth via username and password
133
+ - how to use
134
+ - enable auth-by-http(default is enabled)
135
+ ``` toml
136
+ [dependencies ]
137
+ nacos-sdk = { version = " 0.4" , features = [" default" ] }
138
+ ```
139
+ - Set username and password via environment variables
140
+ ```shell
141
+ export NACOS_CLIENT_USERNAME =you_username
142
+ export NACOS_CLIENT_PASSWORD =you_password
143
+ ```
144
+ - Enable auth-by-http in your code
145
+ ```rust
146
+ ConfigServiceBuilder::new(
147
+ ClientProps::new()
148
+ .server_addr("localhost:8848"))
149
+ .enable_auth_plugin_http()
150
+
151
+ NamingServiceBuilder::new(
152
+ ClientProps::new()
153
+ .server_addr("localhost:8848"))
154
+ .enable_auth_plugin_http()
155
+ .build()
156
+ ```
157
+ - auth-by-aliyun
158
+ - support aliyun ram auth via access-key and access-secret
159
+ - how to use
160
+ - enable auth-by-aliyun feature in toml
161
+ ```toml
162
+ [dependencies ]
163
+ nacos-sdk = { version = " 0.4" , features = [" default" , " auth-by-aliyun" ] }
164
+ ```
165
+ - Set accessKey and secretKey via environment variables
166
+ ```shell
167
+ export NACOS_CLIENT_ACCESS_KEY =you_access_key
168
+ export NACOS_CLIENT_SECRET_KEY =you_secret_key
169
+ ```
170
+ - Enable aliyun ram auth plugin in code by enable_auth_plugin_aliyun
171
+ ```rust
172
+ ConfigServiceBuilder::new(
173
+ ClientProps::new()
174
+ .server_addr("localhost:8848"))
175
+ .enable_auth_plugin_aliyun()
176
+
177
+ NamingServiceBuilder::new(
178
+ ClientProps::new()
179
+ .server_addr("localhost:8848"))
180
+ .enable_auth_plugin_aliyun()
181
+ .build()
182
+ ```
124
183
125
184
# # 开发说明
126
185
- Build with `cargo build`
@@ -181,7 +240,7 @@ gRPC 交互的 Payload 和 Metadata 由 `Protocol Buffers` 序列化,具体的
181
240
# ### Common 通用能力
182
241
- [x] 创建参数,自定义传参 + ENV 环境变量读取,后者优先级高;ENV 统一前缀,例如 `NACOS_CLIENT_CONFIG_*` 于配置管理, `NACOS_CLIENT_NAMING_*` 于服务注册
183
242
- [x] 通用客户端请求交互,Request/Response 通用 gRPC 逻辑,提供给 Config/Naming
184
- - [x] Auth 鉴权;账密登陆 username/password,TODO accessKey/secretKey
243
+ - [x] Auth 鉴权;账密登陆 username/password,阿里云RAM鉴权 accessKey/secretKey
185
244
- [x] 通用日志,`tracing::info!()`
186
245
- [ ] Monitor,`opentelemetry`
187
246
- [ ] 数据落盘与加载(用于服务端宕机弱依赖)
0 commit comments