#actix-web #jwt #actix-web-middleware #keycloak #middleware #actix-middleware

actix-web-middleware-keycloak-auth

A middleware for Actix Web that handles authentication with a JWT emitted by Keycloak

9 unstable releases

0.5.0 Sep 29, 2024
0.4.2 Dec 3, 2023
0.4.1 Sep 27, 2023
0.4.0 Apr 5, 2022
0.2.0 Nov 29, 2020

#146 in HTTP server

Download history 82/week @ 2024-11-16 20/week @ 2024-11-23 42/week @ 2024-11-30 60/week @ 2024-12-07 90/week @ 2024-12-14 35/week @ 2024-12-21 43/week @ 2024-12-28 62/week @ 2025-01-04 53/week @ 2025-01-11 68/week @ 2025-01-18 162/week @ 2025-01-25 377/week @ 2025-02-01 347/week @ 2025-02-08 341/week @ 2025-02-15 349/week @ 2025-02-22 297/week @ 2025-03-01

1,398 downloads per month

MIT license

57KB
925 lines

actix-web-middleware-keycloak-auth

LICENSE Build and test Lint Crates.io Version Documentation

A middleware for Actix Web that handles authentication with a JWT emitted by Keycloak.

Features

  • Actix Web middleware
  • deny HTTP requests that do not provide a valid JWT (or choose to allow them and handle the authentication state from a following middleware)
  • require one or several Keycloak realm or client roles to be included in the JWT
  • error HTTP responses sent from the middleware can have generic bodies as well as detailed error reasons
  • access JWT claims from handlers (for example: get the ID of the authenticated user)
  • parse custom JWT claims (using Serde)
  • access parsed roles from handlers (every Keycloak role contained in the JWT)
  • compatible with paperclip using the paperclip_compat feature
  • store auth status in request-local data instead of returning a HTTP response (so that the next middleware/handler can try another auth mechanism, for example)

Usage

License

MIT License Copyright (c) 2020 David Sferruzza

Dependencies

~17–32MB
~531K SLoC