-
Notifications
You must be signed in to change notification settings - Fork 93
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
Gate dependencies behind feature flags #177
base: master
Are you sure you want to change the base?
Conversation
cf53c5a
to
d0967e5
Compare
d0967e5
to
9f1ff8b
Compare
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.
I don't agree with the approach. The two dependencies exist because some of the in-memory primitives come with default policies. However, the only effect of missing the dependencies could be that one must be provided instead of having a default / fallback. Indeed take ClientMap
then it could expose a constructor with an explicit policy argument. Similarly the policy of using rmp-serde
for the token signing could be boxed away as a trait that is provided in the constructor.
This allows the types to exist in principle, even when no default policies are found in the dependencies.
Makes sense. Will try to refactor towards generalizing the implementations over different inner implementations. |
Okay, the abstraction over different de-/serializers is.. a mess. Unless we pull in |
The dispatch need not be byte-compatible with previous version, imo, since in-memory data should be treated as ephemeral. Well, any new design could be validated by trying to swap the current encoding scheme for something like BER or even JWT but those can always live as separate implementations as well. This opens the possibility of having a public wrapper type (with private fields, implementing Serialize) which the policy is to turn into a byte vector. Or rather two methods since there are two different instances of encoding happening. The |
Something like that? @HeroicKatora That's a fully opaque representation that publicly implements The internal representation at the moment is just an enum. |
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.
Pretty much except that I'd prefer dynamic dispatch over a generic. It's a rather large operation where not a lot can be gained from an inline optimization. The only problem here are auto-traits, i.e. Send
and Sync
should still work for the Assertion
. The inner types are all good 👍
73c0738
to
d2785af
Compare
Rewrote the internals to dynamically dispatch instead. Works fine, added the auto traits as a requirement to the trait itself, so that's still fine. |
Fyi, the bulk of this PR looks good. But, from the perspective of secure defaults, I don't yet feel comfortable with an interface doesnt provide some secure configuration of all interfaces for users by default. That means, there should be an easy choice and that one should be secure. In particular, The serializer is not as relevant but still I'm not sold on the idea of making it more difficult to most people (I'm basing this on the fact that this is the first time that issue came up) and not having at least an optional dependency that fully implements the trait. Or, at the very least, there should be good guidance within the trait documentation on how to bind it to a generic serialization library. Just some thoughts here, and why I'm not convinced yet that this PR is ready. |
@HeroicKatora Well, do you think it would be sufficient if we provided a Such as the interfaces that use the And, of course, the And all these features could be enabled by default to make the default experience secure by default. |
@HeroicKatora Hey, sorry for the delay, I wanted to ask if what I proposed in the previous comment would be fine? |
The approach is decent with the trait factoring, but I can't quite get over the modification to Do note that tests can have a dev-dependency on the encoding / hashing crates, maybe that is a direction to use? |
This PR gates the following dependencies behind feature flags:
rust-argon2
rmp-serde
These dependencies are less common dependencies for some web services, since:
a) not everyone uses
rust-argon2
(personally, I use the RustCryptoargon2
crate for pretty much all my projects)b) not everyone uses MessagePack in their projects
In total, this makes the dependency tree 16 dependencies lighter with all features disabled.
Whether these features should be enabled by default or not can definitely be discussed.
All the features are documented on docs.rs using the unstable
doc_auto_cfg
featureI license past and future contributions under the dual MIT/Apache-2.0 license, allowing licensees to chose either at their option.