Crates.io | sylvia-iot-auth |
lib.rs | sylvia-iot-auth |
version | 0.1.15 |
source | src |
created_at | 2023-03-05 14:58:00.301121 |
updated_at | 2024-09-27 12:09:30.809133 |
description | The authentication/authorization module of the Sylvia-IoT platform. |
homepage | |
repository | https://github.com/woofdogtw/sylvia-iot-core.git |
max_upload_size | |
id | 801484 |
size | 975,166 |
The authentication/authorization module of the Sylvia-IoT platform.
This module provides:
You can simply mount sylvia-iot-auth into your axum App:
use axum::Router;
use clap::App as ClapApp;
use std::net::SocketAddr;
use sylvia_iot_auth::{libs, routes};
use tokio::{self, net::TcpListener};
#[tokio::main]
async fn main() -> std::io::Result<()> {
let args = ClapApp::new("your-project-name").get_matches();
let conf = libs::config::read_args(&args);
let auth_state = match routes::new_state("/auth", &conf).await {
Err(e) => {
println!("Error: {}", e);
return Ok(());
},
Ok(state) => state,
};
let app = Router::new().merge(routes::new_service(&auth_state));
let listener = match TcpListener::bind("0.0.0.0:1080").await.unwrap();
axum::serve(listener, app.into_make_service_with_connect_info::<SocketAddr>()).await
}
Please see src/bin/sylvia-iot-auth.rs
to get the real world example.