Skip to main content

Crate qm_keycloak

Crate qm_keycloak 

Source
Expand description

Keycloak integration for authentication and authorization.

This crate provides utilities for managing Keycloak realms, clients, users, roles, and tokens. Keycloak is used for OAuth2/OIDC authentication and role-based access control.

§Features

  • Realm Management: Create and manage Keycloak realms
  • Client Management: Configure OAuth clients with protocols and mappers
  • User Management: Create, update, delete, and authenticate users
  • Role Management: Client and realm roles
  • Token Management: JWT token validation and refresh
  • Session Management: Browser session handling
  • Configuration: Environment-based configuration

§Usage

```ignore use qm_keycloak::{Keycloak, KeycloakConfig};

#tokio::main async fn main() -> anyhow::Result<()> { let config = KeycloakConfig::new()?; let keycloak = Keycloak::new(config).await?; let users = keycloak.get_users(“realm”).await?; Ok(()) } ```

§Environment Variables

VariableDescriptionDefault
KEYCLOAK_URLKeycloak server URLhttp://127.0.0.1:8080
KEYCLOAK_REALMDefault realmmaster
KEYCLOAK_CLIENT_IDClient ID for adminadmin-cli
KEYCLOAK_USERNAMEAdmin username(none)
KEYCLOAK_PASSWORDAdmin password(none)

§Development

In the development environment, Keycloak can be found in a Kubernetes at https://keycloak.qm.local. If Keycloak is missing, you need to run k8s/helm-charts/skaffold/skaffold.infra-1-base.yaml.

Default username/password: admin/Admin123

Re-exports§

pub use token::store::JwtStore;
pub use crate::config::Config as KeycloakConfig;

Modules§

config
Configuration for keycloak.
realm
Realm management.
schema
Schema definitions.
session
Session management.
token
Token handling.
types
validation
Validation utilities.

Macros§

keycloak
Macro to implement AsRef for storage types.

Structs§

AuthenticationExecutionInfoRepresentation
AuthenticationFlowRepresentation
AuthenticatorConfigRepresentation
ClientRepresentation
CredentialRepresentation
GroupRepresentation
IdentityProviderRepresentation
Keycloak
Keycloak client for managing authentication and authorization.
KeycloakAdmin
KeycloakBuilder
Builder for creating Keycloak client instances.
RealmInfo
Realm information for Keycloak including public key.
RealmRepresentation
RoleRepresentation
ServerInfo
Server information for Keycloak.
UserRepresentation

Enums§

KeycloakError

Traits§

KeycloakTokenSupplier

Functions§

idp_signature_and_encryption
Sets up IDP signature and encryption settings.

Type Aliases§

TypeMap