3 unstable releases
|0.2.0||Jul 6, 2022|
|0.1.1||Jul 4, 2022|
|0.1.0||Jul 4, 2022|
#322 in HTTP server
23 downloads per month
JWT authentication middleware for Actix that supports checking for invalidated JWTs without paying the cost of a per-request IO call. It sources invalidated JWTs from a Stream and stores them in memory.
This middleware is based on the assumption that since JWTs (should) have an expiry, ultimately, an in-memory set of explicitly-invalidated-yet-unexpired JWTs that are periodically reloaded should not be overwhelmingly big enough to cause problems. Only testing can truly answer if this assumption works for a given usecase.
- jsonwebtoken for JWT encoding + validation
tracingenables instrumentation by pulling in tracing
logenables logs (via tracing) using the compatibility layer
actix-sessionintegration, allowing you to extract JWTs from a configurable session key.
The example included in this repo has
- A simple set of routes for starting and inspecting the current session
- An in-memory implementation of the invalidated JWT interface
- In-memory loop for purging expired JWTs from the store
- Channel-based Stream of invalidated JWT events for powering the invalidated JWT set used by the middleware
- ring to generate an Ed25519 keypair for EdDSA-signed JWTs
Both session and JWT keys are generated on the fly, so JWTs are incompatible across restarts.
session as features. To run a server on 8080:
cargo run --example inmemory --features tracing,session
/loginto start a session
/logoutto destroy the current session (requires a session)
/sessionto inspect the current session (requires a session)
/maybe_sesionto inspect the current session if it exists
session is not passed, authentication in the example is dependent on
Bearer tokens sent as an
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.