| Crates.io | actix-jwt-authc |
| lib.rs | actix-jwt-authc |
| version | 0.2.0 |
| created_at | 2022-07-04 05:59:10.309191+00 |
| updated_at | 2022-07-06 02:23:30.567182+00 |
| description | Actix middleware for authenticating JWTs with support for invalidation |
| homepage | |
| repository | https://github.com/lloydmeta/actix-jwt-authc |
| max_upload_size | |
| id | 618780 |
| size | 113,779 |
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.
tracing enables instrumentation by pulling in tracinglog enables logs (via tracing) using the compatibility layersession enables actix-session integration, allowing you to extract
JWTs from a configurable session key.The example included in this repo has
Both session and JWT keys are generated on the fly, so JWTs are incompatible across restarts.
It supports tracing and session as features. To run a server on 8080:
cargo run --example inmemory --features tracing,session
Supported endpoints
/login to start a session/logout to destroy the current session (requires a session)/session to inspect the current session (requires a session)/maybe_sesion to inspect the current session if it existsIf session is not passed, authentication in the example is dependent on Bearer tokens sent as an Authorization header.
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.