Skip to content

update to tower-sessions #28

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

daly4
Copy link

@daly4 daly4 commented Nov 15, 2023

update from axum sessions to tower sessions

@daly4
Copy link
Author

daly4 commented Nov 15, 2023

Simple solution to #27 . Unsure if data race problem described in thread is addressed by middleware ordering.

@daly4 daly4 force-pushed the feature/tower-sessions branch from 37d3dcf to 8ead8e2 Compare November 18, 2023 16:04
@LeoniePhiline
Copy link
Owner

Hi and thanks for your PR!

The data race problem described in #28 will persist until tower-sessions exposes per-session data locks to the user.

Until then, I cannot make tower-sessions the default, but I would like to offer tower-sessions support behind a non-default feature flag.

What do you think?

@daly4
Copy link
Author

daly4 commented Nov 24, 2023

Sounds wise to me.

@daly4
Copy link
Author

daly4 commented Jan 8, 2024

updated to axum 0.7.3 and tower-sessions v0.9.1

@LeoniePhiline
Copy link
Owner

Thank you! ♥️

I still intend to integrate this - I just need to find the time.

@daly4
Copy link
Author

daly4 commented Jan 9, 2024

no worries, fix failed cargo sort on .toml files

@avtrujillo
Copy link

avtrujillo commented Jun 25, 2024

I'm getting a SessionLayerMissing error from inside <CsrfMiddleware as tower_service::Service<Request<B>>>::call() when I try to handle a request:

pub async fn build_router(pg_pool: sqlx::Poolsqlx::Postgres, db_conn: Arc, state: MyState) -> Result<axum::Router<()>, MainErr> {

...

let session_layer = authn::session_layer(pg_pool).await.map_err(|e| {
    MainErr::SessionLayer(e)
})?;

...

.layer(CsrfLayer::new().regenerate(RegenerateToken::PerUse))
.layer(session_layer)

.with_state(state);

This is with tower-sessions 0.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants