4 releases
0.1.3 | Oct 14, 2024 |
---|---|
0.1.2 | Oct 3, 2024 |
0.1.1 | Oct 3, 2024 |
0.1.0 | Sep 11, 2024 |
#218 in Authentication
185 downloads per month
42KB
936 lines
identity_dbus_broker
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.
Features
- SessionBroker: Handles D-Bus requests related to session authentication.
- DeviceBroker: Manages device-related authentication.
- HimmelblauBroker: Includes a session service implementation that forwards
SessionBroker
requests to the HimmelblauBroker system D-Bus service, located atorg.samba.himmelblau
.
The traits provided by this crate simplify the implementation of these D-Bus services.
Example Usage
Himmelblau Session Broker Example
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
}
Himmelblau System Broker Example
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.eyJhdWQiOiJlZjFkYTlkNC1mZjc3LTRjM2UtYTAwN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WxpQG1pY3Jvc29mdC5jb20iLCJ1dGkiOiJGVnNHeFlYSTMwLVR1aWt1dVVvRkFBIiwidmVyIjoiMS4wIn0.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
}
Getting Started
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()
Licensing
identity_dbus_broker
is licensed under the LGPL-3.0 license, making it suitable for use in both open source and proprietary projects.
Contributions
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.
Dependencies
~9–19MB
~269K SLoC