Turreta Rust Keycloak Crate

Turreta Rust Keycloak is a crate that enables Rust codes to work with Keycloak. Moreover, it supports multiple recent versions of Keycloak. It is a Rust library (aka crate) that provides API to work with Keycloak for user authentication, authorization, and access token validation. We have developed the crate as one of the essential components for our future projects that use the Rust programming language. As we develop those future projects, we get to test and improve the crate over time.

Rust Keycloak Crate Quickstart

There are two ways to use the crate as a dependency in a Rust codebase. Supposed the current version of the crate is 1.0.0, we could craft our Cargo.toml in one of the following ways.

First, we could use a published version of the library. As a published crate, it is available on crates.io which the Rust community’s crate registry.

Alternatively, we could use a release version from its online Git repository on GitHub. In this case, we specify the GitHub repository URL for the Turreta Rust Keycloak crate.

Contexts and Credentials

The Turreta Rust Keycloak crate uses the idea of context whenever our Rust codes authenticates, validates, or performs operations on behalf of a user. A context is specific to a Keycloak client (i.e., client_id and client_secret). Within a context, we work with user credentials, roles, and permissions.

Consider the following codes.