#actix-web #client #logging #user #service #indie-auth #indieauth

bin+lib indieauth-client

A small library for actix-web to log your users in using IndieAuth

1 unstable release

new 0.1.0 Jan 30, 2025

#442 in HTTP server

AGPL-3.0

22KB
271 lines

IndieAuth.rs

A simple implementation of IndieAuth in Rust.

Client

The client library is made for actix-web. This is the all you need:

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    use actix_identity::IdentityMiddleware;
    use actix_session::{storage::CookieSessionStore, SessionMiddleware};
    use indieauth_client::{get_service, AuthConfig};

    let config = AuthConfig::new("localhost:8080".to_string()); // change this to your own domain

    let secret_key = actix_web::cookie::Key::generate();

    actix_web::HttpServer::new(move || {
        actix_web::App::new()
            .wrap(IdentityMiddleware::default())
            .wrap(SessionMiddleware::new(
                CookieSessionStore::default(),
                secret_key.clone(),
            ))
            .service(index)
            .service(get_service(&config))
    })
    .workers(1)
    .bind("127.0.0.1:8080")?
    .run()
    .await
}

Try it out

git clone https://codeberg.org/jak2k/indieauth.rs.git
cd indieauth.rs
cd indieauth-client
cargo run localhost:8080 # this is the issuer. If you run it on your own domain, you need to change this to that domain

If you run it on localhost using http, you will need to change the URL in the addressbar to http manually.

FediAuth-Server

An IndieAuth provider that support logging in with a fediverse account.

Dependencies

~18–30MB
~522K SLoC