Skip to content

realaravinth/actix-auth-middleware

Repository files navigation

Actix Authentication Middleware

Documentation Build codecov

dependency status

Checks if session is authenticated


What

This library provides a generic middleware to protect authenticated routes from unauthenticated access. The middleware provides options to customise authentication checking mechanism, which enables it to support a wide range of session management mechanisms.

If a session is authenticated, then the request will be dispatched to the matching handler and if unauthenticated, it will be redirected to a user specified route, ideally a sign in route.

Usage

Add this to your Cargo.toml:

[dependencies.actix-auth-middleware]
version = "0.2.0"
git = "https://github.com/realaravinth/actix-auth-middleware"
# if using https://crates.io/crates/actix-identity, uncomment the
#following line:
#features = ["actix-identity"]

Example

  1. Cookie session management: source : cookie-identity.rs
    cargo run --example cookie-identity