rullst-connect

Projects that follow the best practices below can voluntarily self-certify and show that they've achieved an Open Source Security Foundation (OpenSSF) best practices badge.

There is no set of practices that can guarantee that software will never have defects or vulnerabilities; even formal methods can fail if the specifications or assumptions are wrong. Nor is there any set of practices that can guarantee that a project will sustain a healthy and well-functioning development community. However, following best practices can help improve the results of projects. For example, some practices enable multi-person review before release, which can both help find otherwise hard-to-find technical vulnerabilities and help build trust and a desire for repeated interaction among developers from different companies. To earn a badge, all MUST and MUST NOT criteria must be met, all SHOULD criteria must be met OR be unmet with justification, and all SUGGESTED criteria must be met OR unmet (we want them considered at least). If you want to enter justification text as a generic comment, instead of being a rationale that the situation is acceptable, start the text block with '//' followed by a space. Feedback is welcome via the GitHub site as issues or pull requests There is also a mailing list for general discussion.

We gladly provide the information in several locales, however, if there is any conflict or inconsistency between the translations, the English version is the authoritative version.
If this is your project, please show your baseline badge status on your project page! The baseline badge status looks like this: Baseline badge level for project 13360 is in_progress Here is how to embed the baseline badge:
You can show your baseline badge status by embedding this in your markdown file:
[![OpenSSF Baseline](https://www.bestpractices.dev/projects/13360/baseline)](https://www.bestpractices.dev/projects/13360)
or by embedding this in your HTML:
<a href="https://www.bestpractices.dev/projects/13360"><img src="https://www.bestpractices.dev/projects/13360/baseline"></a>


These are the Baseline Level 1 criteria. These are criteria version v2026.02.19.

Baseline Series: Baseline Level 1 Baseline Level 2 Baseline Level 3

        

 Basics

  • General

    Note that other projects may use the same name.

    Rust Connect is an elegant, async-first, and Developer Experience (DX) focused OAuth2 authentication library for Rust,

    Please use SPDX license expression format; examples include "Apache-2.0", "BSD-2-Clause", "BSD-3-Clause", "GPL-2.0+", "LGPL-3.0+", "MIT", and "(BSD-2-Clause OR Ruby)". Do not include single quotes or double quotes.
    If there is more than one language, list them as comma-separated values (spaces optional) and sort them from most to least used. If there is a long list, please list at least the first three most common ones. If there is no language (e.g., this is a documentation-only or test-only project), use the single character "-". Please use a conventional capitalization for each language, e.g., "JavaScript".
    The Common Platform Enumeration (CPE) is a structured naming scheme for information technology systems, software, and packages. It is used in a number of systems and databases when reporting vulnerabilities.

    Rullst Connect 🦀

    Crates.io
    Downloads
    Documentation
    License: MIT
    Rust Version

    Rullst Connect is an elegant, async-first, and Developer Experience (DX) focused OAuth2 authentication library for Rust. It simplifies the integration of social logins into your Rust web applications, providing a standardized interface across multiple providers.

    🛡️ Quality & Security Audits

    CI & Coverage Security & Analysis Formal & Advanced Testing
    CI Build<br>Coverage<br>Spellcheck CodeQL<br>Cargo Deny<br>Machete<br>OpenSSF Scorecard Fuzz Testing<br>Mutants<br>Kani
    Publish Semver Checks Zero Panics<br>Audit: 10/10

    ✨ Features

    • 🚀 Async & Fast: Built on top of tokio and reqwest.
    • 🧩 Standardized: All providers return a unified ConnectUser struct.
    • 🛡️ Type-Safe: Robust error handling using thiserror (ConnectError).
    • 🔌 Framework Agnostic: Works seamlessly with Rullst, Axum, Actix, Leptos, Dioxus, or any other framework.
    • 🔐 Enterprise Security: Built-in OIDC Discovery, JWKS validation, and automated CSRF tower-sessions.
    • 📺 Device Flow: Native RFC 8628 support for headless CLI and Smart TV auth.
    • 🛠️ Testing: Embedded Mock IdP router for seamless offline local E2E testing.

    📚 Important Documents:

    📦 Supported Providers

    Official support for 11 core providers:

    1. Google
    2. GitHub
    3. Microsoft / Azure AD
    4. Apple (Sign in with Apple)
    5. Auth0
    6. AWS Cognito
    7. Facebook
    8. X (Twitter) (Strict PKCE requirement)
    9. Discord
    10. LinkedIn
    11. OIDC (OpenID Connect Custom Provider)

    🛠️ 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:

    cargo add rullst-connect
    

    Or manually add it to your Cargo.toml:

    [dependencies]
    rullst-connect = "10.0.1"
    tokio = { version = "1.52", features = ["full"] }
    

    🚀 Quick Start

    1. Initialize the Provider

    Choose your provider and pass your credentials and callback URL:

    use rullst_connect::prelude::*;
    
    let github = GithubProvider::new(
        "YOUR_CLIENT_ID".to_string(),
        "YOUR_CLIENT_SECRET".to_string(),
        "http://localhost:3000/auth/github/callback".to_string(),
    );
    

    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:

    let params = rullst_connect::provider::ExchangeParams {
        auth_code: code,
        ..Default::default()
    };
    match github.get_user(params).await {
        Ok(user) => {
            println!("Welcome, {}!", user.name);
            println!("Email: {:?}", user.email);
            println!("Avatar: {:?}", user.avatar_url);
        }
        Err(_) => return (StatusCode::INTERNAL_SERVER_ERROR, "Failed to get user".to_string()),
    }
    

    🛡️ 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(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("existing_refresh_token_string").await?;
    // Tokens are wrapped in `secrecy::SecretString` to prevent accidental log leakage ([REDACTED]).
    // When you need to send it to an API, expose it explicitly:
    use secrecy::ExposeSecret;
    let raw_token = refreshed_user.access_token.expose_secret();
    println!("Successfully refreshed token securely!");
    

    🔒 PKCE Support (v9.0.0+)

    All providers natively support PKCE (Proof Key for Code Exchange) to mitigate authorization code interception attacks. Some providers like X (Twitter) v2 strictly require it.

    use rullst_connect::pkce::generate_pkce;
    
    // 1. Generate challenge and verifier
    let (code_verifier, code_challenge) = 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(&code_challenge).redirect_url();
    
    // 4. In the callback route, fetch the user using the saved verifier:
    let params = rullst_connect::provider::ExchangeParams {
        auth_code: &code,
        code_verifier: Some(&code_verifier),
        ..Default::default()
    };
    let user = provider.get_user(params).await.unwrap();
    

    🧑‍💻 Full Example with Axum

    You can find a complete working server using the Axum framework in the examples directory. Just run:

    cargo run --example axum_server
    

    📦 Releasing a New Version

    This project uses cargo-release to automate version bumps, README synchronization, and CHANGELOG management.
    The publish workflow in .github/workflows/publish.yml runs when a vX.Y.Z tag is pushed, and it can also be triggered manually from GitHub Actions.

    To release a new version, simply run:

    # install it first if you haven't: cargo install cargo-release
    cargo release patch --execute  # for v1.0.x patches
    cargo release minor --execute  # for v1.x.0 features
    cargo release major --execute  # for vX.0.0 breaking changes
    

    This will automatically bump versions, tag the release, and push to GitHub, triggering the crates.io publish workflow.

    For the exact release checklist and what to do next time, see RELEASING.md.

    🤝 Contributing

    Feel free to open Issues and submit Pull Requests! Want to add a new provider? It's easy! Just implement the Provider trait.

    <!-- ## Contributors ✨ Thanks! <a href="https://github.com/Rullst/rullst-connect/graphs/contributors"> <img src="https://contrib.rocks/image?repo=Rullst/rullst-connect" /> </a> -->

    📄 License

    This project is licensed under the MIT License.

 Controls 0/24

  • Controls


    When a user attempts to read or modify a sensitive resource in the project's authoritative repository, the system MUST require the user to complete a multi-factor authentication process. [OSPS-AC-01.01]
    Enforce multi-factor authentication for the project's version control system, requiring collaborators to provide a second form of authentication when accessing sensitive data or modifying repository settings. Passkeys are acceptable for this control.


    When a new collaborator is added, the version control system MUST require manual permission assignment, or restrict the collaborator permissions to the lowest available privileges by default. [OSPS-AC-02.01]
    Most public version control systems are configured in this manner. Ensure the project's version control system always assigns the lowest available permissions to collaborators by default when added, granting additional permissions only when necessary.


    When a direct commit is attempted on the project's primary branch, an enforcement mechanism MUST prevent the change from being applied. [OSPS-AC-03.01]
    If the VCS is centralized, set branch protection on the primary branch in the project's VCS. Alternatively, use a decentralized approach, like the Linux kernel's, where changes are first proposed in another repository, and merging changes into the primary repository requires a specific separate act.


    When an attempt is made to delete the project's primary branch, the version control system MUST treat this as a sensitive activity and require explicit confirmation of intent. [OSPS-AC-03.02]
    Set branch protection on the primary branch in the project's version control system to prevent deletion.


    When a CI/CD pipeline operates on untrusted metadata, those parameters MUST be sanitized and validated prior to use in the pipeline. [OSPS-BR-01.01]
    CI/CD pipelines should sanitize (quote, escape or exit on expected values) all metadata inputs which correspond to untrusted sources. This includes data such as branch names, commit messages, tags, pull request titles, and author information.


    When a CI/CD pipeline operates on untrusted code snapshots, it MUST prevent access to privileged CI/CD credentials and assets. [OSPS-BR-01.03]
    CI/CD pipelines should isolate untrusted code snapshots from privileged credentials and assets. In particular, projects should be careful to ensure that workflows which build or execute code prior to review by a collaborator do not have access to CI/CD credentials.


    When the project lists a URI as an official project channel, that URI MUST be exclusively delivered using encrypted channels. [OSPS-BR-03.01]
    Configure the project's websites and version control systems to use encrypted channels such as SSH or HTTPS for data transmission. Ensure all tools and domains referenced in project documentation can only be accessed via encrypted channels.


    When the project lists a URI as an official distribution channel, that channel MUST be protected from adversary-in-the-middle attacks using cryptographically authenticated channels. [OSPS-BR-03.02]
    Artifacts distributed by the project should be distributed through channels which ensure integrity and authenticity. Use of HTTPS for downloads, signed releases, or distribution through trusted package managers are all acceptable methods to protect against adversary-in-the-middle attacks.


    The project MUST prevent the unintentional storage of unencrypted sensitive data, such as secrets and credentials, in the version control system. [OSPS-BR-07.01]
    Configure .gitignore or equivalent to exclude files that may contain sensitive information. Use pre-commit hooks and automated scanning tools to detect and prevent the inclusion of sensitive data in commits.


    When the project has made a release, the project documentation MUST include user guides for all basic functionality. [OSPS-DO-01.01]
    Create user guides or documentation for all basic functionality of the project, explaining how to install, configure, and use the project's features. If there are any known dangerous or destructive actions available, include highly-visible warnings.


    When the project has made a release, the project documentation MUST include a guide for reporting defects. [OSPS-DO-02.01]
    It is recommended that projects use their VCS default issue tracker. If an external source is used, ensure that the project documentation and contributing guide clearly and visibly explain how to use the reporting system. It is recommended that project documentation also sets expectations for how defects will be triaged and resolved.


    While active, the project MUST have one or more mechanisms for public discussions about proposed changes and usage obstacles. [OSPS-GV-02.01]
    Establish one or more mechanisms for public discussions within the project, such as mailing lists, instant messaging, or issue trackers, to facilitate open communication and feedback.


    While active, the project documentation MUST include an explanation of the contribution process. [OSPS-GV-03.01]
    Create a CONTRIBUTING.md or CONTRIBUTING/ directory to outline the contribution process including the steps for submitting changes, and engaging with the project maintainers.


    While active, the license for the source code MUST meet the OSI Open Source Definition or the FSF Free Software Definition. [OSPS-LE-02.01]
    Add a LICENSE file to the project's repo with a license that is an approved license by the Open Source Initiative (OSI), or a free license as approved by the Free Software Foundation (FSF). Examples of such licenses include the MIT, BSD 2-clause, BSD 3-clause revised, Apache 2.0, Lesser GNU General Public License (LGPL), and the GNU General Public License (GPL). Releasing to the public domain meets this control if there are no other encumbrances such as patents.


    While active, the license for the released software assets MUST meet the OSI Open Source Definition or the FSF Free Software Definition. [OSPS-LE-02.02]
    If a different license is included with released software assets, ensure it is an approved license by the Open Source Initiative (OSI), or a free license as approved by the Free Software Foundation (FSF). Examples of such licenses include the MIT, BSD 2-clause, BSD 3-clause revised, Apache 2.0, Lesser GNU General Public License (LGPL), and the GNU General Public License (GPL). Note that the license for the released software assets may be different than the source code.


    While active, the license for the source code MUST be maintained in the corresponding repository's LICENSE file, COPYING file, or LICENSE/ directory. [OSPS-LE-03.01]
    Include the project's source code license in the project's LICENSE file, COPYING file, or LICENSE/ directory to provide visibility and clarity on the licensing terms. The filename MAY have an extension. If the project has multiple repositories, ensure that each repository includes the license file.


    While active, the license for the released software assets MUST be included in the released source code, or in a LICENSE file, COPYING file, or LICENSE/ directory alongside the corresponding release assets. [OSPS-LE-03.02]
    Include the project's released software assets license in the released source code, or in a LICENSE file, COPYING file, or LICENSE/ directory alongside the corresponding release assets to provide visibility and clarity on the licensing terms. The filename MAY have an extension. If the project has multiple repositories, ensure that each repository includes the license file.


    While active, the project's source code repository MUST be publicly readable at a static URL. [OSPS-QA-01.01]
    Use a common VCS such as GitHub, GitLab, or Bitbucket. Ensure the repository is publicly readable. Avoid duplication or mirroring of repositories unless highly visible documentation clarifies the primary source. Avoid frequent changes to the repository that would impact the repository URL. Ensure the repository is public.


    The version control system MUST contain a publicly readable record of all changes made, who made the changes, and when the changes were made. [OSPS-QA-01.02]
    Use a common VCS such as GitHub, GitLab, or Bitbucket to maintain a publicly readable commit history. Avoid squashing or rewriting commits in a way that would obscure the author of any commits.


    When the package management system supports it, the source code repository MUST contain a dependency list that accounts for the direct language dependencies. [OSPS-QA-02.01]
    This may take the form of a package manager or language dependency file that enumerates all direct dependencies such as package.json, Gemfile, or go.mod.


    Projects with multiple repositories MUST document a list of codebases that are part of the project. [OSPS-QA-04.01]
    Document any additional subproject code repositories produced by the project and compiled into a release. This documentation should include the status and intent of the respective codebase.


    While active, the version control system MUST NOT contain generated executable artifacts. [OSPS-QA-05.01]
    Remove generated executable artifacts in the project's version control system. It is recommended that any scenario where a generated executable artifact appears critical to a process such as testing, it should be instead be generated at build time or stored separately and fetched during a specific well-documented pipeline step.


    While active, the version control system MUST NOT contain unreviewable binary artifacts. [OSPS-QA-05.02]
    Do not add any unreviewable binary artifacts to the project's version control system. This includes executable application binaries, library files, and similar artifacts. It does not include assets such as graphical images, sound or music files, and similar content typically stored in a binary format.


    While active, the project documentation MUST contain security contacts. [OSPS-VM-02.01]
    Create a security.md (or similarly-named) file that contains security contacts for the project.


This data is available under the Community Data License Agreement – Permissive, Version 2.0 (CDLA-Permissive-2.0). This means that a Data Recipient may share the Data, with or without modifications, so long as the Data Recipient makes available the text of this agreement with the shared Data. Please credit @venelouis and the OpenSSF Best Practices badge contributors.

Project badge entry owned by: @venelouis.
Entry created on 2026-06-24 15:16:13 UTC, last updated on 2026-06-24 15:29:00 UTC. Last achieved passing badge on 2026-06-24 15:29:00 UTC.