#user-management #iot #oauth2 #client #platform #authorization #authentication

bin lib sylvia-iot-auth

The authentication/authorization module of the Sylvia-IoT platform

52 releases

0.1.16 Dec 20, 2024
0.1.15 Sep 27, 2024
0.1.12 Aug 31, 2024
0.1.6 Jul 30, 2024
0.0.6 Mar 31, 2023

#216 in HTTP server

Download history 190/week @ 2024-09-11 179/week @ 2024-09-18 243/week @ 2024-09-25 83/week @ 2024-10-02 7/week @ 2024-10-09 4/week @ 2024-10-16 3/week @ 2024-10-23 1/week @ 2024-10-30 1/week @ 2024-11-06 3/week @ 2024-11-13 6/week @ 2024-11-20 7/week @ 2024-11-27 19/week @ 2024-12-04 79/week @ 2024-12-11 134/week @ 2024-12-18 7/week @ 2024-12-25

240 downloads per month
Used in 4 crates

MIT license

310KB
8K SLoC

crates.io Documentation CI Coverage Docker License

sylvia-iot-auth

The authentication/authorization module of the Sylvia-IoT platform.

This module provides:

  • OAuth2 authorization that supports the following grant flows:
    • Authorization code
    • Client credentials (to be implemented)
  • User management.
  • Client management.

Documentation

Mount sylvia-iot-auth in your axum App

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.

Dependencies

~78MB
~1.5M SLoC