Replies: 3 comments 18 replies
-
Thanks for working on this! I appreciate you taking an interest in this tricky problem. I've looked over the branch you mentioned and here are a few quick thoughts: At a high level I would prefer we not introduce a new type and instead rip the bandage off. Because we're pre-1.0, we have more leeway here to make breaking changes. I'd also rather introduce breaking changes than introduce a second set of types which need to be maintained and will ultimately need to be removed anyway. On a more granular level, I'm not sure the OnceCell approach will work and more specifically we will want to ensure that we are not removing the trace logs in the process: the suspicious activity warning is required by OWASP, for instance. Moreover the semantic of Option regarding the record is important and so either it shouldn't be changed or if it is it needs to be done so carefully so as not to change the current semantic.
Just to make sure we're on the same page here, we have around 70% coverage, with doctests providing unit-style tests of the session interface (these are run by CI). I'm not opposed to adding more tests, extending tests by adding a test mod, etc but I did want to make sure you had seen those. Regarding testing, I think it could make sense to introduce tests independently from the interface changes: those we can merge right away and continue to extend as the interface is evolved to address the collision problem. Please let me know how I can be helpful. 😁 |
Beta Was this translation helpful? Give feedback.
-
A thought I had here to help ease the transition to a new method could look something like this: #[async_trait]
pub trait SessionStore: Debug + Send + Sync + 'static {
/// A method for saving a session in a store.
async fn create(&self, session_id: &Id) -> Result<()> {
self.default_create(session_id).await
}
#[deprecated(note = "Please implement the `create` method directly. This default implementation will be removed in the future.")]
async fn default_create(&self, session_id: &Id) -> Result<()> {
self.save(session_id).await
}
/// A method for saving a session in a store.
async fn save(&self, session_record: &Record) -> Result<()>;
/// A method for loading a session from a store.
async fn load(&self, session_id: &Id) -> Result<Option<Record>>;
/// A method for deleting a session from a store.
async fn delete(&self, session_id: &Id) -> Result<()>;
} |
Beta Was this translation helpful? Give feedback.
-
Regarding testing, I'm adding some additional service tests as we work on introducing signing and encryption over here: 90eb541 |
Beta Was this translation helpful? Give feedback.
-
So, I have been working on banging out some experiments on how to change the code in order to prevent id generation collisions (after discussion on #169). Due to the need for a major version change for any of the real improvements, I think it would be better to engage with this in a more iterative fashion. With regard to changing and maintaining, I have run into the following serious problems with the code:
So, I think this gives us an opportunity to do some pretty serious refactoring. You can see the very beginnings of where I am heading at here. This branch is currently a PoC and not ready for merging. It's just to give a little structure to this conversation.
The important piece of those changes is that I am introducing testing infrastructure and completely new types called NewSessionStore and NewSession. These will be used to make any incompatible changes with the current SessionStore and Session. I will try to factor as much code out of Session and SessionStore so that it is used by the old and the new versions. Once that is in progress, I am hoping a more concrete plan for making the major version change can be formed.
As it stands, I will probably hide the new stuff behind a feature flag that we can make not default until the major version change. This is not done in the branch, I will probably modify the branch to include a commit adding the feature before adding the types.
The next steps I plan on taking are literally breaking up some of the files (especially tower-session-core/src/session.rs).
I am also pretty uncomfortable with the logic that's currently embedded into the Session impl. I am hoping we can zhuzh that around a bit to make testing easier.
Does anyone, especially @maxcountryman, have any thoughts about this?
Thanks! wt
Beta Was this translation helpful? Give feedback.
All reactions