Rullst Connect 🦀
Rullst Connect is an elegant, async-first, and Developer Experience (DX) focused OAuth2 authentication library for Rust, heavily inspired by Laravel Socialite. It simplifies the integration of social logins into your Rust web applications, providing a standardized interface across multiple providers.
✨ Features
- 🚀 Async & Fast: Built on top of
tokioandreqwest. - 🧩 Standardized: All providers return a unified
ConnectUserstruct. - 🛡️ Type-Safe: Robust error handling using
thiserror(ConnectError). - 🔌 Framework Agnostic: Works seamlessly with Rullst, Axum, Actix, Leptos, Dioxus, or any other framework.
📚 Important Documents:
- CHANGELOG.md: See what's new in v5.0.2.
- ROADMAP.md: Discover our path to v1.0.0.
- AUDIT.md: Complete security, performance, and maintainability audit report.
📦 Supported Providers (v5.2.0)
Official support for 33 major providers:
- GitHub
- X (Twitter) (with PKCE support)
- Apple (Sign in with Apple)
- Microsoft / Azure AD
- AWS Cognito
- Auth0
- Okta
- Discord
- Spotify
- Twitch
- GitLab
- Bitbucket
- Slack
- Patreon
- Zoom
- Dropbox
- Notion
- Stripe
- DigitalOcean
- TikTok
- Snapchat
- Line
- VK (VKontakte)
- Yahoo
- Basecamp
- Linear
- Asana
🛠️ Installation
Add the package to your Cargo.toml. If you use Rullst, Axum, Actix, or Leptos, you can enable their specific features for native Extractor support!
You can either run:
Or manually add it to your Cargo.toml:
[]
= "5.2.3"
= { = "1.52", = ["full"] }
🚀 Quick Start
1. Initialize the Provider
Choose your provider and pass your credentials and callback URL:
use *;
let github = new;
2. Redirect the User
Get the authorization URL and redirect your user:
let url = github.redirect_url;
// Example in Axum: return Redirect::temporary(&url);
3. Handle the Callback & Get User
When the user returns to your callback URL with a code query parameter, exchange it for a ConnectUser:
match github.get_user.await
🛡️ CSRF Protection (State Parameter)
To prevent Cross-Site Request Forgery (CSRF) attacks, you should generate a secure random string, save it in a session/cookie, and pass it to the provider.
// 1. Generate a random state string and save it in the session
let state = "random_secure_string";
// 2. Get the authorization URL with the state parameter using the builder
let url = github.with_state.redirect_url;
// return Redirect::temporary(&url);
// 3. In the callback route, verify if the query param `state` matches your session!
// If you are using the optional `axum` or `actix` features, you can use `verify_state`:
// params.verify_state(&state_from_session)?;
🔄 Refreshing Tokens
If an access token expires, you can seamlessly renew it without asking the user to login again by using their refresh_token:
let refreshed_user = github.refresh_token.await?;
println!;
🔒 PKCE Support (e.g. X / Twitter)
Some providers like X (Twitter) v2 strictly require PKCE (Proof Key for Code Exchange). We provide a built-in helper for this.
use generate_pkce;
// 1. Generate challenge and verifier
let = generate_pkce;
// 2. Save `code_verifier` in the user's session or a secure HttpOnly cookie!
// 3. Get the URL with PKCE natively using the builder pattern
let auth_url = provider.with_pkce.redirect_url;
// 4. In the callback route, fetch the user using the saved verifier:
let user = provider.get_user_with_pkce.await.unwrap;
🧑💻 Full Example with Axum
You can find a complete working server using the Axum framework in the examples directory. Just run:
📦 Releasing a New Version
This project uses cargo-release to automate version bumps, README synchronization, and CHANGELOG management.
To release a new version, simply run:
# install it first if you haven't: cargo install cargo-release
This will automatically bump versions, tag the release, and push to GitHub, triggering our CI publish workflow.
🤝 Contributing
Feel free to open Issues and submit Pull Requests! Want to add a new provider? It's easy! Just implement the Provider trait.
📄 License
This project is licensed under the MIT License.