Skip to content

Commit 21e820c

Browse files
committed
bump: nacos-sdk=0.4.2
1 parent 282bce8 commit 21e820c

File tree

5 files changed

+47
-13
lines changed

5 files changed

+47
-13
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
edition = "2021"
33
name = "nacos-sdk-rust-binding-node"
4-
version = "0.4.0"
4+
version = "0.4.2"
55
authors = ["CheirshCai <[email protected]>"]
66
license = "Apache-2.0"
77
readme = "README.md"
@@ -18,7 +18,7 @@ crate-type = ["cdylib"]
1818
napi = { version = "2", default-features = false, features = ["napi4", "async"] }
1919
napi-derive = "2"
2020

21-
nacos-sdk = { version = "0.4.0", features = ["default"] }
21+
nacos-sdk = { version = "0.4.2", features = ["default", "auth-by-aliyun"] }
2222
#nacos-sdk = { git = "https://github.com/nacos-group/nacos-sdk-rust.git", branch = "main", features = ["default"] }
2323

2424
tracing-subscriber = { version = "0.3", features = ["default"] }

index.d.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@
33

44
/* auto-generated by NAPI-RS */
55

6-
export function sum(a: number, b: number): number
6+
export declare function sum(a: number, b: number): number
77
export interface ClientOptions {
88
/** Server Addr, e.g. address:port[,address:port],...] */
99
serverAddr: string
1010
/** Namespace/Tenant */
1111
namespace: string
1212
/** AppName */
1313
appName?: string
14-
/** Username for Auth */
14+
/** Username for Auth, Login by Http with Token */
1515
username?: string
16-
/** Password for Auth */
16+
/** Password for Auth, Login by Http with Token */
1717
password?: string
18+
/** Access_Key for Auth, Login by Aliyun Ram */
19+
accessKey?: string
20+
/** Access_Secret for Auth, Login by Aliyun Ram */
21+
accessSecret?: string
22+
/** Signature_Region_Id for Auth, Login by Aliyun Ram */
23+
signatureRegionId?: string
1824
/** naming push_empty_protection, default true */
1925
namingPushEmptyProtection?: boolean
2026
/** naming load_cache_at_start, default false */

src/config.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,29 @@ impl NacosConfigClient {
3535
);
3636

3737
// need enable_auth_plugin_http with username & password
38-
let is_enable_auth = client_options.username.is_some() && client_options.password.is_some();
38+
let is_enable_auth_http =
39+
client_options.username.is_some() && client_options.password.is_some();
40+
// need enable_auth_plugin_aliyun with access_key & access_secret
41+
let is_enable_auth_aliyun =
42+
client_options.access_key.is_some() && client_options.access_secret.is_some();
3943

40-
let props = if is_enable_auth {
44+
let props = if is_enable_auth_http {
4145
props
4246
.auth_username(client_options.username.unwrap())
4347
.auth_password(client_options.password.unwrap())
48+
} else if is_enable_auth_aliyun {
49+
props
50+
.auth_access_key(client_options.access_key.unwrap())
51+
.auth_access_secret(client_options.access_secret.unwrap())
52+
.auth_signature_region_id(client_options.signature_region_id.unwrap())
4453
} else {
4554
props
4655
};
4756

48-
let config_service_builder = if is_enable_auth {
57+
let config_service_builder = if is_enable_auth_http {
4958
nacos_sdk::api::config::ConfigServiceBuilder::new(props).enable_auth_plugin_http()
59+
} else if is_enable_auth_aliyun {
60+
nacos_sdk::api::config::ConfigServiceBuilder::new(props).enable_auth_plugin_aliyun()
5061
} else {
5162
nacos_sdk::api::config::ConfigServiceBuilder::new(props)
5263
};

src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,16 @@ pub struct ClientOptions {
5050
pub namespace: String,
5151
/// AppName
5252
pub app_name: Option<String>,
53-
/// Username for Auth
53+
/// Username for Auth, Login by Http with Token
5454
pub username: Option<String>,
55-
/// Password for Auth
55+
/// Password for Auth, Login by Http with Token
5656
pub password: Option<String>,
57+
/// Access_Key for Auth, Login by Aliyun Ram
58+
pub access_key: Option<String>,
59+
/// Access_Secret for Auth, Login by Aliyun Ram
60+
pub access_secret: Option<String>,
61+
/// Signature_Region_Id for Auth, Login by Aliyun Ram
62+
pub signature_region_id: Option<String>,
5763
/// naming push_empty_protection, default true
5864
pub naming_push_empty_protection: Option<bool>,
5965
/// naming load_cache_at_start, default false

src/naming.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,29 @@ impl NacosNamingClient {
2929
.naming_load_cache_at_start(client_options.naming_load_cache_at_start.unwrap_or(false));
3030

3131
// need enable_auth_plugin_http with username & password
32-
let is_enable_auth = client_options.username.is_some() && client_options.password.is_some();
32+
let is_enable_auth_http =
33+
client_options.username.is_some() && client_options.password.is_some();
34+
// need enable_auth_plugin_aliyun with access_key & access_secret
35+
let is_enable_auth_aliyun =
36+
client_options.access_key.is_some() && client_options.access_secret.is_some();
3337

34-
let props = if is_enable_auth {
38+
let props = if is_enable_auth_http {
3539
props
3640
.auth_username(client_options.username.unwrap())
3741
.auth_password(client_options.password.unwrap())
42+
} else if is_enable_auth_aliyun {
43+
props
44+
.auth_access_key(client_options.access_key.unwrap())
45+
.auth_access_secret(client_options.access_secret.unwrap())
46+
.auth_signature_region_id(client_options.signature_region_id.unwrap())
3847
} else {
3948
props
4049
};
4150

42-
let naming_service_builder = if is_enable_auth {
51+
let naming_service_builder = if is_enable_auth_http {
4352
nacos_sdk::api::naming::NamingServiceBuilder::new(props).enable_auth_plugin_http()
53+
} else if is_enable_auth_aliyun {
54+
nacos_sdk::api::naming::NamingServiceBuilder::new(props).enable_auth_plugin_aliyun()
4455
} else {
4556
nacos_sdk::api::naming::NamingServiceBuilder::new(props)
4657
};

0 commit comments

Comments
 (0)