Crates.io | identity_dbus_broker |
lib.rs | identity_dbus_broker |
version | 0.1.3 |
source | src |
created_at | 2024-09-11 20:25:40.557493 |
updated_at | 2024-10-14 15:35:13.296243 |
description | DBus Broker which supplies credentials for authenticated Entra ID users |
homepage | https://www.samba.org/ |
repository | https://github.com/himmelblau-idm/identity_dbus_broker |
max_upload_size | |
id | 1372236 |
size | 49,789 |
identity_dbus_broker
is a Rust crate that provides traits for implementing D-Bus services used in Azure Entra ID authentication. It is part of the larger Himmelblau project, aimed at building an identity broker compatible with Microsoft's proprietary Linux Intune Portal. This crate offers two main traits, SessionBroker
and DeviceBroker
, which represent the session D-Bus service com.microsoft.identity.broker1
and system service com.microsoft.identity.DeviceBroker1
, respectively. These services allow for the handling of authentication requests, similar to what Microsoft's proprietary Intune binaries provide.
SessionBroker
requests to the HimmelblauBroker system D-Bus service, located at org.samba.himmelblau
.The traits provided by this crate simplify the implementation of these D-Bus services.
The following is an example of how to use the identity_dbus_broker
crate to start a session broker service that forwards requests to the HimmelblauBroker system service.
use identity_dbus_broker::himmelblau_session_broker_serve;
#[tokio::main]
async fn main() -> Result<(), dbus::MethodErr> {
himmelblau_session_broker_serve().await
}
This example demonstrates how to implement the HimmelblauBroker
trait to handle system-level authentication requests.
use identity_dbus_broker::{HimmelblauBroker, himmelblau_broker_serve};
use libc::uid_t;
struct Broker;
impl HimmelblauBroker for Broker {
fn acquire_token_silently(
&mut self,
protocol_version: String,
correlation_id: String,
request_json: String,
uid: uid_t,
) -> Result<String, dbus::MethodErr> {
eprintln!("The peer uid is {}", uid);
Ok("{
\"access_token\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Imk2bEdrM0ZaenhSY1ViMkMzbkVRN3N5SEpsWSIsImtpZCI6Imk2bEdrM0ZaenhSY1ViMkMzbkVRN3N5SEpsWSJ9.eyJhdWQiOiJlZjFkYTlkNC1mZjc3LTRjM2UtYTAwNS04NDBjM2Y4MzA3NDUiLCJpc3MiOiJodHRw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GVnNHeFlYSTMwLVR1aWt1dVVvRkFBIiwidmVyIjoiMS4wIn0.D3H6pMUtQnoJAGq6AHd\",
\"token_type\": \"Bearer\",
\"expires_in\": 5368
}"
.to_string())
}
fn get_accounts(
&mut self,
protocol_version: String,
correlation_id: String,
request_json: String,
uid: uid_t,
) -> Result<String, dbus::MethodErr> {
eprintln!("The peer uid is {}", uid);
Ok("{
\"accounts\": [
{
\"username\": \"tux@test.onmicrosoft.com\",
\"realm\": \"29a02212-775d-43b2-a073-a265002c7d11\"
}
]
}"
.to_string())
}
// Other methods omitted for brevity
}
#[tokio::main]
async fn main() -> Result<(), dbus::MethodErr> {
himmelblau_broker_serve::<Broker>(Broker {}).await
}
To use this crate, add the following to your Cargo.toml
:
[dependencies]
identity_dbus_broker = "0.1.0"
Then, implement the required traits (SessionBroker
and/or DeviceBroker
) for your project. You can start the respective D-Bus service using the provided functions:
session_broker_serve()
device_broker_serve()
identity_dbus_broker
is licensed under the LGPL-3.0 license, making it suitable for use in both open source and proprietary projects.
Contributions are welcome! If you'd like to collaborate or propose improvements, feel free to open an issue or a pull request.
For more information, check out the Himmelblau project.