gotham-middleware-basicauth
http basic auth middleware for Gotham framework
Usage
this code take from examples/basic-auth/main.rs
use new_pipeline;
use single_pipeline;
use *;
use Router;
use State;
use AuthMiddleware;
as you can ses, it's eazy to use, default
method return a middleware that required
to login as admin with password admin when visiting web site at the first time.
You can create a new middleware manually, codes in example scoped-auth
show how to create a new middleware:
let middleware: AuthMiddleware = AuthMiddleware ;
You can pass a list of user with format "username:password", and a list of path you want to protect by basic auth. Note that if a path is protected, it's subpath will be protected too.
To run these examples, run
or
and then open http://localhost:8000
on your browser.
todo
-
Add scoped protecd path -
More elegant error handle and log output -
Add doc -
Add unit test - Extend protocol to enable logout and login control
-
publish to crates.io -
doc for basic use and scoped path feature