Giter Club home page Giter Club logo

zitadel-rust's Introduction

ZITADEL for Rust   Crates.io docs.rs Crates.io Crates.io

This repository contains the gRPC service clients and helpers/credentials/other utilities for ZITADEL.

The following features are present:

  • API clients for communication with the ZITADEL API (calling gRPC methods)
  • Credentials support for the API clients (access token and service account interceptors)
  • OIDC Introspection support for rocket
  • OIDC Introspection support for axum

Example

There exist a few examples in the examples directory. Go there to see the library in action, or head over to the documentation to see the full API documentation.

Development

After you clone the repository, you need "just" to run certain tasks. Generating the gRPC clients is done via just generate-grpc or just (as it is configured to be the default action for just).

For the generation to complete successfully, you need to have "buf" and the required proto plugins installed.

Required tooling:

  • just
  • buf
  • protoc
  • protoc-gen-prost: cargo install protoc-gen-prost
  • protoc-gen-tonic: cargo install protoc-gen-tonic
  • protoc-gen-prost-crate: cargo install protoc-gen-prost-crate

Installing the tools is also partially available via just install-tools.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the package by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

zitadel-rust's People

Contributors

0xdeafbeef avatar adogcalledspot avatar alienscience avatar buehler avatar emgrav avatar jamil7 avatar kjuulh avatar randoooom avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zitadel-rust's Issues

RUSTSEC-2023-0071: Marvin Attack: potential key recovery through timing sidechannels

Marvin Attack: potential key recovery through timing sidechannels

Details
Package rsa
Version 0.9.5
URL RustCrypto/RSA#19 (comment)
Date 2023-11-22

Impact

Due to a non-constant-time implementation, information about the private key is leaked through timing information which is observable over the network. An attacker may be able to use that information to recover the key.

Patches

No patch is yet available, however work is underway to migrate to a fully constant-time implementation.

Workarounds

The only currently available workaround is to avoid using the rsa crate in settings where attackers are able to observe timing information, e.g. local use on a non-compromised computer is fine.

References

This vulnerability was discovered as part of the "Marvin Attack", which revealed several implementations of RSA including OpenSSL had not properly mitigated timing sidechannel attacks.

See advisory page for additional details.

The automated release is failing 🚨

🚨 The automated release from the main branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the main branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Could not access Cargo.toml

Cannot read properties of undefined (reading 'R_OK')


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

RUSTSEC-2020-0071: Potential segfault in the time crate

Potential segfault in the time crate

Details
Package time
Version 0.1.44
URL time-rs/time#293
Date 2020-11-18
Patched versions >=0.2.23
Unaffected versions =0.2.0,=0.2.1,=0.2.2,=0.2.3,=0.2.4,=0.2.5,=0.2.6

Impact

Unix-like operating systems may segfault due to dereferencing a dangling pointer in specific circumstances. This requires an environment variable to be set in a different thread than the affected functions. This may occur without the user's knowledge, notably in a third-party library.

The affected functions from time 0.2.7 through 0.2.22 are:

  • time::UtcOffset::local_offset_at
  • time::UtcOffset::try_local_offset_at
  • time::UtcOffset::current_local_offset
  • time::UtcOffset::try_current_local_offset
  • time::OffsetDateTime::now_local
  • time::OffsetDateTime::try_now_local

The affected functions in time 0.1 (all versions) are:

  • at
  • at_utc
  • now

Non-Unix targets (including Windows and wasm) are unaffected.

Patches

Pending a proper fix, the internal method that determines the local offset has been modified to always return None on the affected operating systems. This has the effect of returning an Err on the try_* methods and UTC on the non-try_* methods.

Users and library authors with time in their dependency tree should perform cargo update, which will pull in the updated, unaffected code.

Users of time 0.1 do not have a patch and should upgrade to an unaffected version: time 0.2.23 or greater or the 0.3 series.

Workarounds

No workarounds are known.

References

time-rs/time#293

See advisory page for additional details.

Credentials and Reqwest SSL Implementation(s)

TLDR

This crate uses both rustls and openssl. Because openssl can be difficult sometimes, it might be better to standardize on rustls.

Description

When using the credentials feature the following 2 dependencies are activated:

  1. openidconnect
  2. reqwest

openidconnect

The openidconnect dependency is pulled in with its default features:

  • oauth2
  • rustls-tls

These default features pull in the oauth2 dependency which then pulls in reqwest with rusttls-tls enabled.

reqwest

The reqwest dependency is included with its default features. This pulls in openssl when running on Linux/Docker. The final result of this is that the Zitadel crate includes a reqwest dependency that uses both rustls and openssl.

Suggested Solution

Normally, including extra unneeded dependencies is not a big problem, but openssl can be painful when building some docker images which do not include openssl in the base image (e.g Alpine Linux).

There is a simple one line change for this behaviour to standardize on rusttls and I can make a PR for this.

How to set request headers in management client

Hi!

I came across this library and tried to find out how to e.g. modify organization metadata. There is bulk_set_org_metadata, however, the API specification states, that the organization to be modified is set in the headers. Is there a way to set which organization to modify using this client?

This would probably be even more important for things like remove_org, where there is an empty request and the whole information which org to delete is in the headers.

Thank you!

RUSTSEC-2020-0159: Potential segfault in `localtime_r` invocations

Potential segfault in localtime_r invocations

Details
Package chrono
Version 0.4.19
URL chronotope/chrono#499
Date 2020-11-10

Impact

Unix-like operating systems may segfault due to dereferencing a dangling pointer in specific circumstances. This requires an environment variable to be set in a different thread than the affected functions. This may occur without the user's knowledge, notably in a third-party library.

Workarounds

No workarounds are known.

References

See advisory page for additional details.

Update axum to 0.7

Hi, thank you for creating this crate!

Would it be possbile to update axum to 0.7?

I also wondered how one could pass other states to axum through app.with_state() like a mongodb client while using the User extractor.

Optional headers in functions

Add User Grant has a documented optional parameter "x-zitadel-orgid" which is important for the correct execution of the function.

As far as I can tell, there's currently no way to set this header in the current function.

This also applies to other functions.

Actix support?

Hi, been playing for a bit with this module, but can't get it running properly using Actix.
Is there any examples for that specific framework?

Implement Clone for ChainedInterceptor

First of all thanks for this great create!

The Problem

Tonic Service Client are designed to be cloned in Multi-Threading/Multiplexing scenarios. There is a section "Multiplexing-Requests" on this in the tonic docs: https://docs.rs/tonic/latest/tonic/transport/struct.Channel.html#multiplexing-requests

As a result a tonic client implements Clone. When using a client build with this crate, a XXXServiceClient<InterceptedService<TonicChannel, ChainedInterceptor>> is returned. Everything except ChainedInterceptor implements Clone.

I need to use the client in a Multiplexing scenario and require the client to implement a lightweight clone to avoid opening a large number of channels.

The Solution

... is not as trivial as I would have though because ServiceAccountInterceptor requires mutability for the token. I changed it to use Interior Mutability instead.

I also had to introduce a new Interceptor trait which I don't like.
The only reason for the new interceptor trait is the ChainedInterceptor chain method which runs calls via the original Interceptor trait on &mut self. This breaks my interior mutability approach though.

I would argue that even if you decide to stick to the old implementation of the ChainedInterceptor , the changed ServiceAccountInterceptor and AccessTokenInterceptor are better off using interior mutability and can still be used in clone-able clients even though we couldn't use the ClientBuilder to obtain them.

PR is coming in a second, let me know if you have any better ideas!

Support for Additional Claims in Introspection

When authenticating with Zitadel it is possible to add additional scopes, e.g urn:zitadel:iam:user:resourceowner and urn:zitadel:iam:user:metadata. If these scopes are used, it is possible to get extra information when calling OIDC Introspection.

Currently, only the default introspection fields are considered and any extra fields are ignored.

Would you be open to a PR that added support for these extra fields? I was thinking of something like using #[serde(flatten)] to support metadata: serde-rs/serde#941 (comment)

Undocumented protobuf dependency

Building the zitadel crate, also as a dependency, fails with the following error if you don't have protobuf development files installed:

   Compiling zitadel v3.1.9
error: failed to run custom build command for `zitadel v3.1.9`

Caused by:
  process didn't exit successfully: `/home/emelie/[...]/debug/build/zitadel-18a8719d73ee0e93/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=external/zitadel/proto
  cargo:rerun-if-changed=external/protoc-gen-validate
  cargo:rerun-if-changed=external/googleapis
  cargo:rerun-if-changed=external/grpc-gateway

  --- stderr
  Error: Custom { kind: Other, error: "protoc failed: google/protobuf/descriptor.proto: File not found.\ngoogle/protobuf/struct.proto: File not found.\nprotoc-gen-openapiv2/options/openapiv2.proto:5:1: Import \"google/protobuf/struct.proto\" was not found or had errors.\nprotoc-gen-openapiv2/options/openapiv2.proto: \"google.protobuf.Value\" is not defined.\nprotoc-gen-openapiv2/options/openapiv2.proto: \"google.protobuf.Value\" is not defined.\nprotoc-gen-openapiv2/options/openapiv2.proto: \"google.protobuf.Value\" is not defined.\nprotoc-gen-openapiv2/options/openapiv2.proto: \"google.protobuf.Value\" is not defined.\nprotoc-gen-openapiv2/options/openapiv2.proto: \"google.protobuf.Value\" is not defined.\nprotoc-gen-openapiv2/options/openapiv2.proto: \"google.protobuf.Value\" is not defined.\nprotoc-gen-openapiv2/options/openapiv2.proto: \"google.protobuf.Value\" is not defined.\nprotoc-gen-openapiv2/options/annotations.proto:5:1: Import \"google/protobuf/descriptor.proto\" was not found or had errors.\nprotoc-gen-openapiv2/options/annotations.proto:6:1: Import \"protoc-gen-openapiv2/options/openapiv2.proto\" was not found or had errors.\nprotoc-gen-openapiv2/options/annotations.proto:10:8: \"google.protobuf.FileOptions\" is not defined.\nprotoc-gen-openapiv2/options/annotations.proto:17:8: \"google.protobuf.MethodOptions\" is not defined.\nprotoc-gen-openapiv2/options/annotations.proto:24:8: \"google.protobuf.MessageOptions\" is not defined.\nprotoc-gen-openapiv2/options/annotations.proto:31:8: \"google.protobuf.ServiceOptions\" is not defined.\nprotoc-gen-openapiv2/options/annotations.proto:38:8: \"google.protobuf.FieldOptions\" is not defined.\n" }
warning: build failed, waiting for other jobs to finish...

As far as I can tell this isn't documented anywhere. Documenting it could be quite helpful, as it's not immediately obvious what the problem is from the error message. On fedora the required package is protobuf-devel, I would assume it's protobuf-dev on apt-based distros.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.