7 releases
Uses new Rust 2024
| new 0.4.0 | Mar 3, 2026 |
|---|---|
| 0.3.4 | Jan 11, 2026 |
| 0.2.1 | Sep 21, 2025 |
#382 in Configuration
507 downloads per month
Used in wp-error
43KB
979 lines
#orion-sec
简介
orion-sec 提供面向 Galaxy 平台的安全配置加载与脱敏工具,帮助代理或服务在保留数据结构的同时区分明文与敏感字段。核心模块围绕 SecValue<T> 与 SecValueType 类型构建,可在读取 YAML 或环境变量后动态切换字段的明文或加密状态。
核心特性
- 统一的密文标记:通过
SecValue<T>在同一结构中表示敏感与非敏感数值。 - 与
orion-variate无缝协作:支持EnvDict、ValueType及UpperKey样式。 - 配置加载即脱敏:
load_secfile自动从~/.galaxy/sec_value.yml或自定义路径构造安全对象。 - 灵活的路径读取:
ValueGettertrait 支持点语法与数组索引(如A[0].B)。
安装与集成
cargo add orion-sec
或者在 Cargo.toml 中手动加入:
[dependencies]
orion-sec = "0.2"
快速上手
use orion_sec::{load_sec_dict, SecValueType, ValueGetter};
fn main() -> orion_sec::SecResult<()> {
let dict = load_sec_dict()?; // 自动加载并去除 SEC_ 前缀
if let Some(SecValueType::String(db_pass)) = dict.value_get("database.credentials.password") {
println!("Password masked? {}", db_pass.is_secret());
}
Ok(())
}
如需测试不同路径,可设置 GAL_SEC_FILE_PATH=/custom/sec.yml 指向替代文件。
常用命令
cargo fmt --all:统一格式化。cargo clippy --all-targets --all-features -- -D warnings:静态检查。cargo test --all-features -- --test-threads=1:运行核心测试用例。
贡献指南
提交 PR 前请确保通过格式化、Clippy、测试与(如适用)cargo llvm-cov。详细要求见 AGENTS.md。
许可证
本项目采用 MIT License。
Dependencies
~7–14MB
~255K SLoC