Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
nickel-jwt-session
Experimental jwt-based user session for nickel. Suggestions for improvements are welcome.
[]
(https://travis-ci.org/kaj/nickel-jwt-session)
Configuration
By default, nickel-jwt-session will store and look for the token in a cookie named "jwt", and the token will expire in 24 hours. The only required argument to the constructor is a private signing key:
extern crate nickel;
extern crate nickel_jwt_session;
use Nickel;
use SessionMiddleware;
You can also customize the cookie name:
extern crate nickel;
extern crate nickel_jwt_session;
use Nickel;
use ;
Or use Authorization: Bearer headers instead of cookies:
extern crate nickel;
extern crate nickel_jwt_session;
use Nickel;
use ;
And change the number of seconds the token will be valid for:
extern crate nickel;
extern crate nickel_jwt_session;
use Nickel;
use SessionMiddleware;
Usage
When you have a user that you have authenticated, use the set_jwt_user() method to put a new token for that user into the response:
To check to see if you have an authenticated user, use the authorized_user() method:
And to log a user out, call the clear_jwt_user() method:
Examples
Full working examples can be found in the examples directory. Read the [API documentation] (https://rasmus.krats.se/doc/nickel-jwt-session/0.3.0/nickel_jwt_session/).
License
Licensed under either of
- Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.