15 releases (4 major breaking)

12.0.0 Jan 10, 2021
11.0.1 Jan 4, 2021
11.0.0 Aug 28, 2020
10.0.1 Jan 4, 2021
0.2.2 Mar 12, 2020

#74 in Asynchronous

Download history 9/week @ 2020-10-30 22/week @ 2020-11-06 85/week @ 2020-11-13 90/week @ 2020-11-20 28/week @ 2020-11-27 26/week @ 2020-12-04 25/week @ 2020-12-11 2/week @ 2020-12-18 1/week @ 2020-12-25 59/week @ 2021-01-01 33/week @ 2021-01-08 26/week @ 2021-01-15 4/week @ 2021-01-22 3/week @ 2021-01-29 5/week @ 2021-02-05 216/week @ 2021-02-12

127 downloads per month

Unlicense OR MIT

260KB
6K SLoC

Keycloak Admin REST API

Legal

Dual-licensed under MIT or the UNLICENSE.

Features

Implements Keycloak Admin REST API version 12.

Usage

Add dependency to Cargo.toml:

[dependencies]
keycloak = "12"
use keycloak::{KeycloakAdmin, KeycloakAdminToken};
use keycloak::types::*;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {

    let url = "http://localhost:9080";
    let client = reqwest::Client::new();
    let admin_token = KeycloakAdminToken::acquire(url, "admin", "password", &client).await?;

    eprintln!("{:?}", admin_token);

    let admin = KeycloakAdmin::new(url, admin_token, client);

    admin
        .realm_users_post(
            "test",
            UserRepresentation {
                username: Some("user".into()),
                ..Default::default()
            },
        )
        .await?;

    let users = admin
        .realm_users_get(
            "test", None, None, None, None, None, None, None, None, None, None, None, None, None,
        )
        .await?;

    eprintln!("{:?}", users);

    let id = users
        .iter()
        .find(|u| u.username == Some("user".into()))
        .unwrap()
        .id
        .as_ref()
        .unwrap()
        .to_string();

    admin.realm_users_with_id_delete("test", id.as_str()).await?;

    Ok(())
}

Dependencies

~3–7MB
~170K SLoC