potree-auth 0.1.0

Authentication and project management for `potree` point clouds.
Documentation
use std::sync::LazyLock;

use axum::Extension;
use axum::Router;
use axum::routing::get;
use web_route::WebRoute;

use super::super::application::service::AuthenticationService;
use super::route_handlers;
use super::state::State;

pub static LOGIN: LazyLock<WebRoute> = LazyLock::new(|| WebRoute::new("/login"));
pub static CALLBACK: LazyLock<WebRoute> = LazyLock::new(|| WebRoute::new("/callback"));

/// Builds a router that performs OIDC authentication.
///
/// **Note:** There should be an active [`tower_sessions`] middleware available
/// in the router's middleware stack.
pub fn build_router(authentication_service: AuthenticationService) -> Router {
    let state = State {
        authentication_service,
    };

    Router::new()
        .route(&LOGIN, get(route_handlers::login))
        .route(&CALLBACK, get(route_handlers::callback))
        .layer(Extension(state))
}