Go to file
Kasper Juul Hermansen 5ffa008e75
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
chore(deps): update rust crate serde to v1.0.210
2024-09-07 00:46:27 +00:00
crates/nefarious-login feat: will trigger login if no cookie is found 2023-11-30 10:07:27 +01:00
examples feat: with return url 2023-11-21 22:52:22 +01:00
scripts feat: with return url 2023-11-21 21:53:39 +01:00
templates feat: with return url 2023-11-21 21:53:39 +01:00
.drone.yml feat: adding drone 2024-03-30 22:11:42 +01:00
.gitignore feat: with base 2023-10-22 16:55:48 +02:00
Cargo.lock chore(deps): update rust crate serde to v1.0.210 2024-09-07 00:46:27 +00:00
Cargo.toml feat: with upstream axum 2023-11-28 11:46:11 +01:00
cuddle.yaml feat: with return url 2023-11-21 21:53:39 +01:00
LICENSE feat: with license 2023-10-22 22:57:10 +02:00
README.md feat: dummy change 2023-11-01 21:26:35 +01:00
renovate.json Add renovate.json 2023-10-22 17:00:49 +00:00

Nefarious Login

Overview

Nefarious Login is a plug-and-play authentication module designed for effortless integration into business applications. Part of a larger suite of Nefarious tools, it aims to remove the hassle from implementing logins by using various authentication engines like Zitadel.

Quick Start

Install the crate via Cargo:

cargo install nefarious-login

Code Sample

Integrate Nefarious Login into your application. The core setup is about configuring the AuthService as shown below:

#[derive(Debug, Clone, Parser)]
struct Command {
    #[clap(flatten)]
    auth: AuthClap,
}

async fn main() -> anyhow::Result<()> {
    let cmd = Command::parse_from(vec![
        "base",
        "--auth-engine=zitadel", // Can also use a yaml file, or env variables, see app --help for more info
        "--zitadel-authority-url=https://personal-wxuujs.zitadel.cloud",
        "--zitadel-redirect-url=http://localhost:3001/auth/authorized",
        "--zitadel-client-id=<your-client-id>",
        "--zitadel-client-secret=<your-secret>",
        "--session-backend=postgresql",
        "--session-postgres-conn=postgres://como:somenotverysecurepassword@localhost:5432/nefarious-test",
    ]);

    let auth_service = AuthService::new(&cmd.auth).await?;

    // .. Use in axum, raw apis etc. See examples for details
}

Complete code in the main function will be similar to the snippet you provided.

Configuring with CLI

Use these CLI options to set up your authentication:

app
--auth-engine=zitadel
--zitadel-authority-url=https://example.zitadel.cloud
--zitadel-redirect-url=http://localhost:3001/auth/authorized
--zitadel-client-id=your-client-id
--zitadel-client-secret=your-client-secret
--session-backend=postgresql
--session-postgres-conn=postgres://username:password@localhost:5432/dbname

Examples

All examples feature axum integration

License

MIT License.

For more details, see LICENSE.

Contributions

PRs welcome. For major changes, open an issue first.