summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-06-18 16:03:22 -0600
committermo khan <mo@mokhan.ca>2025-06-18 16:03:22 -0600
commit49be33cf65962e865700131623b2f825c23983f1 (patch)
treeb570d654c1506a5efc503f1d8edd6c81aa179afe /src
parent4a9127d92cccae553c937a9615e255662d711761 (diff)
feat: update rpc client to use ability.allowed
Diffstat (limited to 'src')
-rw-r--r--src/client.rs31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/client.rs b/src/client.rs
index aaf42de..b0cfa42 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -1,20 +1,39 @@
+use authz::AllowRequest;
+use authz::ability_client::AbilityClient;
use hello_world::HelloRequest;
use hello_world::greeter_client::GreeterClient;
+pub mod authz {
+ tonic::include_proto!("authz.rpc");
+}
+
pub mod hello_world {
tonic::include_proto!("helloworld");
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- let mut client = GreeterClient::connect("http://[::1]:50051").await?;
+ {
+ let mut client = GreeterClient::connect("http://[::1]:50051").await?;
+ let request = tonic::Request::new(HelloRequest {
+ name: "Tonic".into(),
+ });
+
+ let response = client.say_hello(request).await?;
+ println!("RESPONSE={:?}", response);
+ }
- let request = tonic::Request::new(HelloRequest {
- name: "Tonic".into(),
- });
+ {
+ let request = tonic::Request::new(AllowRequest {
+ subject: "gid://example/User/1".into(),
+ permission: "gid://example/Permission/1".into(),
+ resource: "gid://example/Project/1".into(),
+ });
- let response = client.say_hello(request).await?;
- println!("RESPONSE={:?}", response);
+ let mut client = AbilityClient::connect("http://[::1]:50051").await?;
+ let response = client.allowed(request).await?;
+ println!("RESPONSE={:?}", response);
+ }
Ok(())
}