actix-extras icon indicating copy to clipboard operation
actix-extras copied to clipboard

`generate_session_key()` could be public

Open kakserpom opened this issue 1 year ago • 3 comments

I've implemented my own session store and I had to copy-paste generate_session_key() instead of just calling it.

kakserpom avatar May 15 '24 13:05 kakserpom

SessionState should also be public. It's just a type alias but I also had to copy-paste it.

VaRusLAN avatar May 20 '24 12:05 VaRusLAN

Please open a different issue for the SessionState discussion.


I think the choice to keep it private is that it might not be a good choice for all session implementations and that it just happens to work well for the built-in storage impls.

Seeing the desire to re-use it in 3rd party impls is a good indicator that it should be publicl; I'd accept a PR.

robjtede avatar Jun 09 '24 04:06 robjtede

If someone picks this up and creates a PR I think we should change the implementation to use rand::DistString::sample_string() to remove some unwraps: https://docs.rs/rand/0.8/rand/distributions/trait.DistString.html

robjtede avatar Jun 09 '24 04:06 robjtede

I really appreciate this change, but why does the function have to be hidden specifically behind the redis-session feature? I'm using the function as I'm implementing my own session store, i.e. I'm not using Redis. redis-session introduces a total of 12 new dependencies in my Cargo.lock.

sjoqvist avatar Sep 12 '24 08:09 sjoqvist

@sjoqvist removed the feature guard in v0.10.1

robjtede avatar Sep 12 '24 18:09 robjtede