smartive / zitadel-rust

An implementation of the ZITADEL gRPC API in Rust. Complemented with other useful elements such as ServiceAccount auth.
https://docs.rs/zitadel/latest/zitadel/
Other
48 stars 18 forks source link

Improve introspection cache #567

Closed sprudel closed 3 months ago

sprudel commented 3 months ago

Main goals of this PR:

To achieve this I had to remove the Role generic type parameter introduced in #550 , as this was incompatible with the type erasure for the IntrospectionCache trait types. But there are simple ways to achieve the same convenience on library user side.

buehler commented 3 months ago

Very nice, however: since this will result in a breaking change, I need some kind of description, how users of #550 can work around the removed role feature.

sprudel commented 3 months ago

@buehler where would you prefer to have such documentation?

it is basically a standard extension trait


enum Role {
  Admin,
  Client
}

trait MyExtIntrospectedUser {
    fn role(&self, role: Role) -> Option<..>;
}

impl MyExtIntrospectedUser for IntrospectedUser {
   fn role(&self, role: Role) -> Option<..> {
     // convenience impl here

  }
}
buehler commented 3 months ago

It would be nice to have this in the docs of ZitadelExtraTokenFields struct. There were you removed the role generic. As such, I can also include them as the migration path for the breaking change.

sprudel commented 3 months ago

@buehler I added the example both for the IntrospectedUser and ZitadelExtraTokenFields struct