Comments (6)
If I understand correctly, then this would mean that if I make two calls in succession from an AdminServiceClient
which need different x-zitadel-orgid
headers, then I would need to create two separate clients where one has the additional interceptor and one doesn't.
With the current workaround you can reuse the same client and only add the extra header to each call.
We could also wrap the current workaround in a trait. Something like this:
pub trait WithZitadelHeaders<T>: tonic::IntoRequest<T> {
fn with_orgid(self, id: String) -> Result<tonic::Request<T>> {
let mut request = self.into_request();
request.metada_mut().insert("x-zitadel-orgid", id.try_into()?);
request
}
}
impl<T> WithZitadelHeaders<T> for tonic::IntoRequest<T> {}
It should then be possible to do:
let request = AddUserGrantRequest { ... }.with_orgid("foo".to_string())?;
client.add_user_grant(request)?;
from zitadel-rust.
This seems like the better idea to be frank.
from zitadel-rust.
I've found a workaround (I guess it's the recommended way of doing this):
let request = AddUserGrantRequest { ... };
let mut request = request.into_request();
request.metadata_mut().insert("x-zitadel-orgid", my_org_as_header_val);
client.add_user_grant(request).await
from zitadel-rust.
Hey @aDogCalledSpot
Good call.
Theoretically, we could extend the current way the "chained interceptor" works and let users add specialized interceptors for such use cases.
from zitadel-rust.
What do you imagine this would look like?
I'm not too unhappy with the workaround so unless the proposed solution is substantially more ergonomic it might not be worth the effort compared to simply documenting this workaround.
from zitadel-rust.
I agree with you.
Right now, you have the option to use the ClientBuilder
and then add the chained methods "with access token" or "with service account".
When you build a client, the registered auth method decides which interceptors are attached to the grpc client. The chainedinterceptor is required because of the return type of the client builder. As such, we can always expect a AdminServiceClient<InterceptedService<Channel, ChainedInterceptor>
(or other client, but the "InterceptedService..." is the key part).
Now, in theory, we could allow a with_interceptor
and/or add_interceptor
method in the builder that receives a list of interceptors. When building the clients, we could add these interceptors to the clients. The return type should still be the same, but we have the possibility to add multiple intercpetors to the clients.
That way, you could create an interceptor that simply adds the forementioned header to all calls.
from zitadel-rust.
Related Issues (17)
- The automated release is failing 🚨 HOT 1
- Try to create a fix or feat commit when zitadel repo updates HOT 1
- Undocumented protobuf dependency HOT 2
- How to set request headers in management client HOT 3
- Support for Additional Claims in Introspection HOT 2
- Credentials and Reqwest SSL Implementation(s) HOT 1
- RUSTSEC-2020-0159: Potential segfault in `localtime_r` invocations HOT 1
- Actix support? HOT 4
- RUSTSEC-2023-0071: Marvin Attack: potential key recovery through timing sidechannels
- Update axum to 0.7 HOT 2
- Implement Clone for ChainedInterceptor
- Compile error in api/client.rs HOT 1
- Feature Request: Optional Support for Rocket-Okapi Integration in IntrospectedUser HOT 6
- Feature Request: Enhanced Cookie Authentication Support HOT 2
- RUSTSEC-2020-0071: Potential segfault in the time crate HOT 1
- Add interceptor that updates the service account key after it expires HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zitadel-rust.