#actix-web #actix-web-middleware #jwt #keycloak #middleware #http-response

actix-web-middleware-keycloak-auth

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

8 releases

0.4.2 Dec 3, 2023
0.4.1 Sep 27, 2023
0.4.0 Apr 5, 2022
0.4.0-beta.2 Nov 5, 2021
0.1.0 Nov 25, 2020

#319 in HTTP server

Download history 1/week @ 2023-12-23 23/week @ 2023-12-30 55/week @ 2024-01-06 5/week @ 2024-01-13 156/week @ 2024-01-20 100/week @ 2024-01-27 11/week @ 2024-02-03 62/week @ 2024-02-10 73/week @ 2024-02-17 139/week @ 2024-02-24 63/week @ 2024-03-02 86/week @ 2024-03-09 190/week @ 2024-03-16 62/week @ 2024-03-23 72/week @ 2024-03-30 80/week @ 2024-04-06

412 downloads per month

MIT license

56KB
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

~18–35MB
~589K SLoC