tvallotton / rocket_auth

An implementation for an authentication API for Rocket applications.
https://docs.rs/rocket_auth/
Apache License 2.0
73 stars 35 forks source link

Session is not invalidated after time expires using login_for #61

Open robertsarkozi opened 1 year ago

robertsarkozi commented 1 year ago

login_for method takes a Duration parameter, for how long the user should be logged in, after whose expiration I'm expecting the user to not be authorized anymore. I'm trying this with one minute.

    auth.login_for(&form, std::time::Duration::from_secs(60))
        .await?;

In session/default/mod.rs this sets the auth key for that amout of time, but it seems it doesn't have effect...

    #[throws(Error)]
    fn insert_for(&self, id: i32, key: String, time: Duration) {
        let key = AuthKey {
            expires: time.as_secs() as i64,
            secret: key,
        };
        self.insert(id, key);
    }

User session keeps letting me make requests even after 1 minute has passed.

Shouldn't rocket_auth automatically invalidate the session after expiration?

robertsarkozi commented 1 year ago

A possible solution could be the changes I made in a fork: https://github.com/robertsarkozi/rocket_auth/commit/94bb98cf19749aa71b29bfab5e93f13f9e300137