diff --git a/.github/workflows/space-gateway-docker-push.yml b/.github/workflows/space-gateway-docker-push.yml index b5454e7ec..a4ee3cc17 100644 --- a/.github/workflows/space-gateway-docker-push.yml +++ b/.github/workflows/space-gateway-docker-push.yml @@ -3,7 +3,7 @@ name: Publish rust gateways docker image on: push: paths: - - "backend/gateways/spacegate-lib/**" + - "backend/gateways/spacegate-plugins/**" - "backend/supports/auth/**" - "backend/services/spacegate/**" - "Cargo.toml" diff --git a/Cargo.toml b/Cargo.toml index 515d181bb..cd3adc98c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,35 +3,35 @@ #resolver = "2" members = [ - "backend/basic", - # "backend/spi/*", - "backend/spi/spi-cache", - "backend/spi/spi-search", - "backend/spi/spi-graph", - "backend/spi/spi-kv", - "backend/spi/spi-log", - "backend/spi/spi-object", - "backend/spi/spi-plugin", - "backend/spi/spi-stats", - "backend/spi/spi-reldb", - "backend/gateways/test", - "backend/gateways/spacegate-lib", - "backend/middlewares/*", - "backend/supports/iam", - "backend/supports/auth", - "frontend/enhance-wasm", - "backend/supports/reach", - "backend/services/*", - "frontend/sdks/*", - "frontend/clients/*", + "backend/basic", + # "backend/spi/*", + "backend/spi/spi-cache", + "backend/spi/spi-search", + "backend/spi/spi-graph", + "backend/spi/spi-kv", + "backend/spi/spi-log", + "backend/spi/spi-object", + "backend/spi/spi-plugin", + "backend/spi/spi-stats", + "backend/spi/spi-reldb", + "backend/gateways/test", + "backend/gateways/spacegate-plugins", + "backend/middlewares/*", + "backend/supports/iam", + "backend/supports/auth", + "frontend/enhance-wasm", + "backend/supports/reach", + "backend/services/*", + "frontend/sdks/*", + "frontend/clients/*", ] [workspace.package] version = "0.1.0" authors = [ - "gudaoxuri ", - "hermitCode <17743125563@163.com>", - "RWDai ", + "gudaoxuri ", + "hermitCode <17743125563@163.com>", + "RWDai ", ] homepage = "https://bios.idealworld.group" documentation = "https://bios.idealworld.group" @@ -77,11 +77,11 @@ tardis = { git = "https://github.com/ideal-world/tardis.git", rev = "191f3ec" } # "ext-redis", # "ext-axum", # ] } -spacegate-shell = { git = "https://github.com/ideal-world/spacegate.git", branch = "dev", features = [ - "cache", - "k8s", - "ext-redis", - "ext-axum", +spacegate-shell = { git = "https://github.com/ideal-world/spacegate.git", branch = "master", features = [ + "cache", + "k8s", + "ext-redis", + "ext-axum", ] } spacegate-plugin = { git = "https://github.com/ideal-world/spacegate.git", branch = "master" } diff --git a/backend/basic/src/helper/bios_ctx_helper.rs b/backend/basic/src/helper/bios_ctx_helper.rs index ee3b4781f..ce2d97441 100644 --- a/backend/basic/src/helper/bios_ctx_helper.rs +++ b/backend/basic/src/helper/bios_ctx_helper.rs @@ -37,7 +37,7 @@ where } } -// xxx_check_own function will check the owner is empty or not. +// check_own_xxx function will check the owner is empty or not. pub fn check_own_fill_ctx(request: &Request, funs: &TardisFunsInst, ctx: &mut TardisContext) -> TardisResult<()> { unsafe_check_ctx( request, @@ -60,6 +60,7 @@ pub fn check_own_fill_ctx(request: &Request, funs: &TardisFunsInst, ctx: &mut Ta ) } +// 业务不安全方法,请在接口确定将会使用 `head_key_bios_ctx`(default:'Bios-Ctx')的上下文填充当前上下文 pub fn unsafe_fill_ctx(request: &Request, funs: &TardisFunsInst, ctx: &mut TardisContext) -> TardisResult<()> { unsafe_check_ctx( request, @@ -82,6 +83,7 @@ pub fn unsafe_fill_ctx(request: &Request, funs: &TardisFunsInst, ctx: &mut Tardi ) } +// also see [unsafe_fill_ctx] , only fill the owner. pub fn unsafe_fill_owner_only(request: &Request, funs: &TardisFunsInst, ctx: &mut TardisContext) -> TardisResult<()> { unsafe_check_ctx( request, @@ -94,6 +96,7 @@ pub fn unsafe_fill_owner_only(request: &Request, funs: &TardisFunsInst, ctx: &mu ) } +// also see [unsafe_fill_ctx] , only fill the own_paths. pub fn unsafe_fill_own_paths_only(request: &Request, funs: &TardisFunsInst, ctx: &mut TardisContext) -> TardisResult<()> { unsafe_check_ctx( request, @@ -106,6 +109,7 @@ pub fn unsafe_fill_own_paths_only(request: &Request, funs: &TardisFunsInst, ctx: ) } +// also see [unsafe_fill_ctx] , only fill the roles. pub fn unsafe_fill_roles_only(request: &Request, funs: &TardisFunsInst, ctx: &mut TardisContext) -> TardisResult<()> { unsafe_check_ctx( request, @@ -125,6 +129,7 @@ pub fn unsafe_fill_roles_only(request: &Request, funs: &TardisFunsInst, ctx: &mu ) } +// also see [unsafe_fill_ctx] , only fill the groups. pub fn unsafe_fill_groups_only(request: &Request, funs: &TardisFunsInst, ctx: &mut TardisContext) -> TardisResult<()> { unsafe_check_ctx( request, diff --git a/backend/basic/src/helper/request_helper.rs b/backend/basic/src/helper/request_helper.rs index be39f62ed..9c44a75f9 100644 --- a/backend/basic/src/helper/request_helper.rs +++ b/backend/basic/src/helper/request_helper.rs @@ -5,6 +5,7 @@ use tardis::{ pub const REMOTE_ADDR: &str = "remote-addr"; +// Add ip to context pub async fn add_ip(ip: Option, ctx: &TardisContext) -> TardisResult<()> { if let Some(ip) = ip { ctx.add_ext(REMOTE_ADDR, &ip).await?; diff --git a/backend/basic/src/process/ci_processor.rs b/backend/basic/src/process/ci_processor.rs index 47471308b..27ad7319d 100644 --- a/backend/basic/src/process/ci_processor.rs +++ b/backend/basic/src/process/ci_processor.rs @@ -21,6 +21,7 @@ impl Default for AppKeyConfig { } } +// signature ak pub fn signature(app_key_config: &AppKeyConfig, method: &str, path: &str, query: &str, mut header: Vec<(String, String)>) -> TardisResult> { let sorted_req_query = sort_query(query); let date = Utc::now().format("%a, %d %b %Y %T GMT").to_string(); diff --git a/backend/gateways/spacegate-lib/Cargo.toml b/backend/gateways/spacegate-plugins/Cargo.toml similarity index 95% rename from backend/gateways/spacegate-lib/Cargo.toml rename to backend/gateways/spacegate-plugins/Cargo.toml index 9c55e8efe..9d216dc4d 100644 --- a/backend/gateways/spacegate-lib/Cargo.toml +++ b/backend/gateways/spacegate-plugins/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "spacegate-lib" +name = "spacegate-plugins" version.workspace = true authors.workspace = true homepage.workspace = true @@ -19,7 +19,9 @@ lazy_static.workspace = true spacegate-shell.workspace = true spacegate-plugin = { workspace = true, features = ["schema"], optional = true } -bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = ["spi_log"] } +bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = [ + "spi_log", +] } jsonpath-rust = "0.3.1" diff --git a/backend/gateways/spacegate-lib/schema/anti_replay.json b/backend/gateways/spacegate-plugins/schema/anti_replay.json similarity index 100% rename from backend/gateways/spacegate-lib/schema/anti_replay.json rename to backend/gateways/spacegate-plugins/schema/anti_replay.json diff --git a/backend/gateways/spacegate-lib/schema/anti_xss.json b/backend/gateways/spacegate-plugins/schema/anti_xss.json similarity index 100% rename from backend/gateways/spacegate-lib/schema/anti_xss.json rename to backend/gateways/spacegate-plugins/schema/anti_xss.json diff --git a/backend/gateways/spacegate-lib/schema/audit_log.json b/backend/gateways/spacegate-plugins/schema/audit_log.json similarity index 100% rename from backend/gateways/spacegate-lib/schema/audit_log.json rename to backend/gateways/spacegate-plugins/schema/audit_log.json diff --git a/backend/gateways/spacegate-lib/schema/opres.json b/backend/gateways/spacegate-plugins/schema/opres.json similarity index 100% rename from backend/gateways/spacegate-lib/schema/opres.json rename to backend/gateways/spacegate-plugins/schema/opres.json diff --git a/backend/gateways/spacegate-lib/schema/rewrite_ns.json b/backend/gateways/spacegate-plugins/schema/rewrite_ns.json similarity index 100% rename from backend/gateways/spacegate-lib/schema/rewrite_ns.json rename to backend/gateways/spacegate-plugins/schema/rewrite_ns.json diff --git a/backend/gateways/spacegate-lib/src/consts.rs b/backend/gateways/spacegate-plugins/src/consts.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/consts.rs rename to backend/gateways/spacegate-plugins/src/consts.rs diff --git a/backend/gateways/spacegate-lib/src/extension.rs b/backend/gateways/spacegate-plugins/src/extension.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/extension.rs rename to backend/gateways/spacegate-plugins/src/extension.rs diff --git a/backend/gateways/spacegate-lib/src/extension/audit_log_param.rs b/backend/gateways/spacegate-plugins/src/extension/audit_log_param.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/extension/audit_log_param.rs rename to backend/gateways/spacegate-plugins/src/extension/audit_log_param.rs diff --git a/backend/gateways/spacegate-lib/src/extension/before_encrypt_body.rs b/backend/gateways/spacegate-plugins/src/extension/before_encrypt_body.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/extension/before_encrypt_body.rs rename to backend/gateways/spacegate-plugins/src/extension/before_encrypt_body.rs diff --git a/backend/gateways/spacegate-lib/src/extension/cert_info.rs b/backend/gateways/spacegate-plugins/src/extension/cert_info.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/extension/cert_info.rs rename to backend/gateways/spacegate-plugins/src/extension/cert_info.rs diff --git a/backend/gateways/spacegate-lib/src/extension/request_crypto_status.rs b/backend/gateways/spacegate-plugins/src/extension/request_crypto_status.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/extension/request_crypto_status.rs rename to backend/gateways/spacegate-plugins/src/extension/request_crypto_status.rs diff --git a/backend/gateways/spacegate-lib/src/lib.rs b/backend/gateways/spacegate-plugins/src/lib.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/lib.rs rename to backend/gateways/spacegate-plugins/src/lib.rs diff --git a/backend/gateways/spacegate-lib/src/marker.rs b/backend/gateways/spacegate-plugins/src/marker.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/marker.rs rename to backend/gateways/spacegate-plugins/src/marker.rs diff --git a/backend/gateways/spacegate-lib/src/plugin.rs b/backend/gateways/spacegate-plugins/src/plugin.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/plugin.rs rename to backend/gateways/spacegate-plugins/src/plugin.rs diff --git a/backend/gateways/spacegate-lib/src/plugin/anti_replay.rs b/backend/gateways/spacegate-plugins/src/plugin/anti_replay.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/plugin/anti_replay.rs rename to backend/gateways/spacegate-plugins/src/plugin/anti_replay.rs diff --git a/backend/gateways/spacegate-lib/src/plugin/anti_xss.rs b/backend/gateways/spacegate-plugins/src/plugin/anti_xss.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/plugin/anti_xss.rs rename to backend/gateways/spacegate-plugins/src/plugin/anti_xss.rs diff --git a/backend/gateways/spacegate-lib/src/plugin/audit_log.rs b/backend/gateways/spacegate-plugins/src/plugin/audit_log.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/plugin/audit_log.rs rename to backend/gateways/spacegate-plugins/src/plugin/audit_log.rs diff --git a/backend/gateways/spacegate-lib/src/plugin/auth.rs b/backend/gateways/spacegate-plugins/src/plugin/auth.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/plugin/auth.rs rename to backend/gateways/spacegate-plugins/src/plugin/auth.rs diff --git a/backend/gateways/spacegate-lib/src/plugin/auth/tests.rs b/backend/gateways/spacegate-plugins/src/plugin/auth/tests.rs similarity index 99% rename from backend/gateways/spacegate-lib/src/plugin/auth/tests.rs rename to backend/gateways/spacegate-plugins/src/plugin/auth/tests.rs index 80427cb80..22a72b415 100644 --- a/backend/gateways/spacegate-lib/src/plugin/auth/tests.rs +++ b/backend/gateways/spacegate-plugins/src/plugin/auth/tests.rs @@ -15,7 +15,7 @@ use testcontainers_modules::redis::Redis; #[tokio::test] async fn test() { - env::set_var("RUST_LOG", "info,spacegate-lib=trace,bios_auth=trace,tardis=trace"); + env::set_var("RUST_LOG", "info,spacegate-plugins=trace,bios_auth=trace,tardis=trace"); tracing_subscriber::fmt::init(); let docker = testcontainers::clients::Cli::default(); diff --git a/backend/gateways/spacegate-lib/src/plugin/ip_time.rs b/backend/gateways/spacegate-plugins/src/plugin/ip_time.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/plugin/ip_time.rs rename to backend/gateways/spacegate-plugins/src/plugin/ip_time.rs diff --git a/backend/gateways/spacegate-lib/src/plugin/ip_time/ip_time_rule.rs b/backend/gateways/spacegate-plugins/src/plugin/ip_time/ip_time_rule.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/plugin/ip_time/ip_time_rule.rs rename to backend/gateways/spacegate-plugins/src/plugin/ip_time/ip_time_rule.rs diff --git a/backend/gateways/spacegate-lib/src/plugin/ip_time/tests.rs b/backend/gateways/spacegate-plugins/src/plugin/ip_time/tests.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/plugin/ip_time/tests.rs rename to backend/gateways/spacegate-plugins/src/plugin/ip_time/tests.rs diff --git a/backend/gateways/spacegate-lib/src/plugin/ip_time/tests/testconfig.json b/backend/gateways/spacegate-plugins/src/plugin/ip_time/tests/testconfig.json similarity index 100% rename from backend/gateways/spacegate-lib/src/plugin/ip_time/tests/testconfig.json rename to backend/gateways/spacegate-plugins/src/plugin/ip_time/tests/testconfig.json diff --git a/backend/gateways/spacegate-lib/src/plugin/op_redis_publisher.rs b/backend/gateways/spacegate-plugins/src/plugin/op_redis_publisher.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/plugin/op_redis_publisher.rs rename to backend/gateways/spacegate-plugins/src/plugin/op_redis_publisher.rs diff --git a/backend/gateways/spacegate-lib/src/plugin/rewrite_ns_b_ip.rs b/backend/gateways/spacegate-plugins/src/plugin/rewrite_ns_b_ip.rs similarity index 100% rename from backend/gateways/spacegate-lib/src/plugin/rewrite_ns_b_ip.rs rename to backend/gateways/spacegate-plugins/src/plugin/rewrite_ns_b_ip.rs diff --git a/backend/gateways/spacegate-lib/tests/export_schemas.rs b/backend/gateways/spacegate-plugins/tests/export_schemas.rs similarity index 100% rename from backend/gateways/spacegate-lib/tests/export_schemas.rs rename to backend/gateways/spacegate-plugins/tests/export_schemas.rs diff --git a/backend/services/spacegate/Cargo.toml b/backend/services/spacegate/Cargo.toml index b4d5b25b0..2528daf95 100644 --- a/backend/services/spacegate/Cargo.toml +++ b/backend/services/spacegate/Cargo.toml @@ -15,9 +15,15 @@ publish.workspace = true [dependencies] serde.workspace = true lazy_static.workspace = true -spacegate-shell = { workspace = true, features = ["k8s", "plugin-all", "ext-redis", "ext-axum", "cache"] } +spacegate-shell = { workspace = true, features = [ + "k8s", + "plugin-all", + "ext-redis", + "ext-axum", + "cache", +] } tardis = { workerspace = true } -spacegate-lib = { path = "../../gateways/spacegate-lib" } +spacegate-plugins = { path = "../../gateways/spacegate-plugins" } envy = "0.4" [dev-dependencies] pprof = { version = "0.13", features = ["flamegraph"] } diff --git a/backend/services/spacegate/build.sh b/backend/services/spacegate/build.sh index e4cc2a133..688faa10b 100644 --- a/backend/services/spacegate/build.sh +++ b/backend/services/spacegate/build.sh @@ -34,7 +34,7 @@ fi # cargo update; cargo build $RUST_BUILD_ARG; -mv ../../target/$TARGET_DIR/bios-spacegate ./ +mv ../../../target/$TARGET_DIR/bios-spacegate ./ ### Docker diff --git a/backend/services/spacegate/src/main.rs b/backend/services/spacegate/src/main.rs index 79db09e9f..4df476f3e 100644 --- a/backend/services/spacegate/src/main.rs +++ b/backend/services/spacegate/src/main.rs @@ -1,5 +1,5 @@ use serde::Deserialize; -use spacegate_lib::register_lib_plugins; +use spacegate_plugins::register_lib_plugins; use spacegate_shell::plugin::SgPluginRepository; use spacegate_shell::BoxError; use tardis::basic::tracing::TardisTracing; diff --git a/backend/supports/iam/src/basic/serv/iam_open_serv.rs b/backend/supports/iam/src/basic/serv/iam_open_serv.rs index a3386f1fa..45c8a7ba0 100644 --- a/backend/supports/iam/src/basic/serv/iam_open_serv.rs +++ b/backend/supports/iam/src/basic/serv/iam_open_serv.rs @@ -78,6 +78,7 @@ impl IamOpenServ { icon: spec_req.icon.clone(), scope_level: spec_req.scope_level.clone(), disabled: spec_req.disabled, + ext: spec_req.url.clone(), ..Default::default() }, funs, @@ -92,6 +93,7 @@ impl IamOpenServ { kind: IamResKind::Spec, scope_level: spec_req.scope_level.clone(), disabled: spec_req.disabled, + ext: spec_req.url.clone(), ..Default::default() }, funs, @@ -142,6 +144,7 @@ impl IamOpenServ { kind: IamResKind::Spec, scope_level: spec.scope_level.clone(), disabled: spec.disabled, + ext: spec.url.clone(), ..Default::default() }, funs,