ldap_backend/src/main.rs

40 lines
1.1 KiB
Rust
Raw Normal View History

2023-07-30 02:50:13 +01:00
use skynet_ldap_backend::{
db_init, get_config,
methods::{account_new, account_recover, account_update},
2023-07-30 02:50:13 +01:00
State,
};
2023-05-26 00:02:12 +01:00
#[async_std::main]
async fn main() -> tide::Result<()> {
let config = get_config();
let db = db_init(&config).await?;
2023-05-26 00:02:12 +01:00
let host_port = config.host_port.clone();
tide::log::start();
let state = State {
db,
config,
};
let mut app = tide::with_state(state);
2023-08-06 14:43:49 +01:00
// for users to update their own profile
app.at("/ldap/update").post(account_update::submit);
2023-08-06 18:11:07 +01:00
2023-08-06 14:43:49 +01:00
// for new users
app.at("/ldap/new/email").post(account_new::email::submit);
app.at("/ldap/new/account").post(account_new::account::submit);
2023-08-06 18:11:07 +01:00
2023-08-06 14:43:49 +01:00
// for folks who forget password/username
2023-08-06 14:39:45 +01:00
app.at("/ldap/recover/password").post(account_recover::password::reset);
app.at("/ldap/recover/password/auth").post(account_recover::password::auth);
app.at("/ldap/recover/username").post(account_recover::username::submit);
app.at("/ldap/recover/ssh/request").post(account_recover::ssh::request);
app.at("/ldap/recover/ssh/verify").post(account_recover::ssh::verify);
2023-05-26 00:02:12 +01:00
app.listen(host_port).await?;
Ok(())
}