diff --git a/README.md b/README.md new file mode 100644 index 0000000..30cecbe --- /dev/null +++ b/README.md @@ -0,0 +1,85 @@ +# 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: + +```bash +cargo install nefarious-login +``` + +## Code Sample + +Integrate `Nefarious Login` into your application. The core setup is about +configuring the `AuthService` as shown below: + +```rust +#[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=", + "--zitadel-client-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: + +```bash +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 + +- **Basic Setup**: Check out [examples/basic](./examples/basic) for a minimal + implementation. +- **Using with Clap**: For integrating with Clap, see + [examples/clap](./examples/clap). + +## License + +MIT License. + +For more details, see [LICENSE](./LICENSE). + +## Links + +- Crate: + [nefarious-login on crates.io](https://crates.io/crates/nefarious-login) + +## Contributions + +PRs welcome. For major changes, open an issue first. diff --git a/examples/basic/src/main.rs b/examples/basic/src/main.rs index a840a0f..8f5939d 100644 --- a/examples/basic/src/main.rs +++ b/examples/basic/src/main.rs @@ -41,7 +41,7 @@ async fn main() -> anyhow::Result<()> { }, session: nefarious_login::session::SessionClap { postgresql: PostgresqlSessionClap { - conn: Some("postgres://como:somenotverysecurepassword@localhost:5432/como".into()), + conn: Some("postgres://nefarious-test:somenotverysecurepassword@localhost:5432/nefarious-test".into()), }, }, }; diff --git a/examples/clap/src/main.rs b/examples/clap/src/main.rs index 3d5c98f..ebf6a82 100644 --- a/examples/clap/src/main.rs +++ b/examples/clap/src/main.rs @@ -39,7 +39,7 @@ async fn main() -> anyhow::Result<()> { "--zitadel-client-id=237412977047895154@nefarious-test", "--zitadel-client-secret=rWwDi8gjNOyuMFKoOjNSlhjcVZ1B25wDh6HsDL27f0g2Hb0xGbvEf0WXFY2akOlL", "--session-backend=postgresql", - "--session-postgres-conn=postgres://como:somenotverysecurepassword@localhost:5432/como", + "--session-postgres-conn=postgres://nefarious-test:somenotverysecurepassword@localhost:5432/nafarious-test", ]); let auth_service = AuthService::new(&cmd.auth).await?;