-
Notifications
You must be signed in to change notification settings - Fork 759
feat: Simple OPA support #644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hi @GatewayJ , Thank you for your contribution. Could you provide some additional documentation? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements OPA (Open Policy Agent) support for RustFS, enabling external policy evaluation for S3 requests. It adds a new policy plugin system that integrates with OPA for authorization decisions.
- Adds OPA integration with HTTP client configuration and policy evaluation
- Implements async authorization filtering for bucket operations using OPA
- Integrates OPA plugin into the IAM system with configuration management
Reviewed Changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/run.sh | Adds commented OPA configuration environment variables |
| rustfs/src/storage/ecfs.rs | Replaces synchronous bucket filtering with async stream processing for OPA authorization |
| crates/utils/src/certs.rs | Adds explicit type annotation for domain_name variable |
| crates/policy/src/policy/policy.rs | Removes unnecessary blank line |
| crates/policy/src/policy/opa.rs | New OPA integration module with client, validation, and policy evaluation |
| crates/policy/src/policy.rs | Exposes opa module publicly |
| crates/policy/Cargo.toml | Adds dependencies for OPA functionality (rustfs-config, reqwest, chrono, tracing) |
| crates/obs/Cargo.toml | Adds opa feature to rustfs-config dependency |
| crates/iam/src/sys.rs | Integrates OPA plugin into IAM system with lazy initialization and authorization checks |
| crates/iam/src/lib.rs | Removes unnecessary blank line |
| crates/iam/Cargo.toml | Adds rustfs-config and once_cell dependencies |
| crates/ecstore/src/config/mod.rs | Removes unnecessary blank line |
| crates/config/src/opa/mod.rs | New module defining OPA environment variable constants |
| crates/config/src/lib.rs | Adds opa module under feature flag |
| crates/config/Cargo.toml | Adds opa feature flag |
| .vscode/launch.json | Adds OPA configuration to debug environment |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
7bab58e to
04f70d4
Compare
功能概述此PR为RustFS实现了OPA(开放策略代理)支持,使S3请求能够进行外部策略判断。 插件架构它添加了一个新的策略插件系统,用于向外部OPA服务发送鉴权请求。 初始化流程
鉴权流程
该插件需要的环境变量配置为
输出给外部opa服务的参数为:
account: 用户账户标识符
bucket: 目标存储桶名称
action: 正在执行的具体操作
conditions: 额外的上下文条件 注意事项
快速开始指南
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 16 out of 17 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Could you please add some more test cases? Great! Thank you. |
houseme
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is an unused dependency crate, please remove it, thank you
@loverustfs Does it refer to the code for unit testing |
6c4b344 to
3c9ffa5
Compare
@houseme I've been a bit busy lately and my code is a bit sloppy. Sorry that. I have made some modifications to the code, please review it carefully |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 14 out of 15 changed files in this pull request and generated 4 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 14 out of 15 changed files in this pull request and generated 5 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| match opa::lookup_config().await { | ||
| Ok(conf) => { | ||
| if conf.enable() { | ||
| Self::set_policy_plugin_client(opa::AuthZPlugin::new(conf)).await; | ||
| info!("OPA plugin enabled"); | ||
| } | ||
| } | ||
| Err(e) => { | ||
| error!("Error loading OPA configuration err:{}", e); | ||
| } | ||
| }; |
Copilot
AI
Oct 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spawned task is not awaited or handled, which means initialization errors could be silently ignored and the OPA client might not be properly initialized before authorization requests are made. Consider using a proper initialization mechanism or at least storing the task handle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't OPA initialization errors affect the main process? Provide error logs for easy troubleshooting?
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
@houseme I have resolved some issues, please also pay attention to some Copilot comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GatewayJ Thank you. Please add the content related to 'Copyright' in the header of the new file.
already done |
Type of Change
Related Issues
Summary of Changes
对于s3请求实现opa对接
Checklist
make pre-commitImpact
Additional Notes
Thank you for your contribution! Please ensure your PR follows the community standards (CODE_OF_CONDUCT.md) and sign the CLA if this is your first contribution.