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 badge status on your project page! The badge status looks like this: Badge level for project 13360 is passing Here is how to embed it:
You can show your badge status by embedding this in your markdown file:
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/13360/badge)](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/badge"></a>


These are the Gold level criteria. You can also view the Passing or Silver level criteria.

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

        

 Basics 0/5

  • 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.

  • Prerequisites


    The project MUST achieve a silver level badge. [achieve_silver]

  • Project oversight


    The project MUST have a "bus factor" of 2 or more. (URL required) [bus_factor]
    A "bus factor" (aka "truck factor") is the minimum number of project members that have to suddenly disappear from a project ("hit by a bus") before the project stalls due to lack of knowledgeable or competent personnel. The truck-factor tool can estimate this for projects on GitHub. For more information, see Assessing the Bus Factor of Git Repositories by Cosentino et al.


    The project MUST have at least two unassociated significant contributors. (URL required) [contributors_unassociated]
    Contributors are associated if they are paid to work by the same organization (as an employee or contractor) and the organization stands to benefit from the project's results. Financial grants do not count as being from the same organization if they pass through other organizations (e.g., science grants paid to different organizations from a common government or NGO source do not cause contributors to be associated). Someone is a significant contributor if they have made non-trivial contributions to the project in the past year. Examples of good indicators of a significant contributor are: written at least 1,000 lines of code, contributed 50 commits, or contributed at least 20 pages of documentation.

  • Other


    The project MUST include a license statement in each source file. This MAY be done by including the following inside a comment near the beginning of each file: SPDX-License-Identifier: [SPDX license expression for project]. [license_per_file]
    This MAY also be done by including a statement in natural language identifying the license. The project MAY also include a stable URL pointing to the license text, or the full license text. Note that the criterion license_location requires the project license be in a standard location. See this SPDX tutorial for more information about SPDX license expressions. Note the relationship with copyright_per_file, whose content would typically precede the license information.

 Change Control 1/4

  • Public version-controlled source repository


    The project's source repository MUST use a common distributed version control software (e.g., git or mercurial). [repo_distributed]
    Git is not specifically required and projects can use centralized version control software (such as subversion) with justification.

    Repository on GitHub, which uses git. git is distributed.



    The project MUST clearly identify small tasks that can be performed by new or casual contributors. (URL required) [small_tasks]
    This identification is typically done by marking selected issues in an issue tracker with one or more tags the project uses for the purpose, e.g., up-for-grabs, first-timers-only, "Small fix", microtask, or IdealFirstBug. These new tasks need not involve adding functionality; they can be improving documentation, adding test cases, or anything else that aids the project and helps the contributor understand more about the project.


    The project MUST require two-factor authentication (2FA) for developers for changing a central repository or accessing sensitive data (such as private vulnerability reports). This 2FA mechanism MAY use mechanisms without cryptographic mechanisms such as SMS, though that is not recommended. [require_2FA]


    The project's two-factor authentication (2FA) SHOULD use cryptographic mechanisms to prevent impersonation. Short Message Service (SMS) based 2FA, by itself, does NOT meet this criterion, since it is not encrypted. [secure_2FA]
    A 2FA mechanism that meets this criterion would be a Time-based One-Time Password (TOTP) application that automatically generates an authentication code that changes after a certain period of time. Note that GitHub supports TOTP.

 Quality 0/7

  • Coding standards


    The project MUST document its code review requirements, including how code review is conducted, what must be checked, and what is required to be acceptable. (URL required) [code_review_standards]
    See also two_person_review and contribution_requirements.


    The project MUST have at least 50% of all proposed modifications reviewed before release by a person other than the author, to determine if it is a worthwhile modification and free of known issues which would argue against its inclusion [two_person_review]

  • Working build system


    The project MUST have a reproducible build. If no building occurs (e.g., scripting languages where the source code is used directly instead of being compiled), select "not applicable" (N/A). (URL required) [build_reproducible]
    A reproducible build means that multiple parties can independently redo the process of generating information from source files and get exactly the same bit-for-bit result. In some cases, this can be resolved by forcing some sort order. JavaScript developers may consider using npm shrinkwrap and webpack OccurrenceOrderPlugin. GCC and clang users may find the -frandom-seed option useful. The build environment (including the toolset) can often be defined for external parties by specifying the cryptographic hash of a specific container or virtual machine that they can use for rebuilding. The reproducible builds project has documentation on how to do this.

  • Automated test suite


    A test suite MUST be invocable in a standard way for that language. (URL required) [test_invocation]
    For example, "make check", "mvn test", or "rake test" (Ruby).

    Warning: URL required, but no URL found.



    The project MUST implement continuous integration, where new or changed code is frequently integrated into a central code repository and automated tests are run on the result. (URL required) [test_continuous_integration]
    In most cases this means that each developer who works full-time on the project integrates at least daily.

    Warning: URL required, but no URL found.



    The project MUST have FLOSS automated test suite(s) that provide at least 90% statement coverage if there is at least one FLOSS tool that can measure this criterion in the selected language. [test_statement_coverage90]


    The project MUST have FLOSS automated test suite(s) that provide at least 80% branch coverage if there is at least one FLOSS tool that can measure this criterion in the selected language. [test_branch_coverage80]

 Security 0/5

  • Use basic good cryptographic practices

    Note that some software does not need to use cryptographic mechanisms. If your project produces software that (1) includes, activates, or enables encryption functionality, and (2) might be released from the United States (US) to outside the US or to a non-US-citizen, you may be legally required to take a few extra steps. Typically this just involves sending an email. For more information, see the encryption section of Understanding Open Source Technology & US Export Controls.

    The software produced by the project MUST support secure protocols for all of its network communications, such as SSHv2 or later, TLS1.2 or later (HTTPS), IPsec, SFTP, and SNMPv3. Insecure protocols such as FTP, HTTP, telnet, SSLv3 or earlier, and SSHv1 MUST be disabled by default, and only enabled if the user specifically configures it. If the software produced by the project does not support network communications, select "not applicable" (N/A). [crypto_used_network]


    The software produced by the project MUST, if it supports or uses TLS, support at least TLS version 1.2. Note that the predecessor of TLS was called SSL. If the software does not use TLS, select "not applicable" (N/A). [crypto_tls12]

  • Secured delivery against man-in-the-middle (MITM) attacks


    The project website, repository (if accessible via the web), and download site (if separate) MUST include key hardening headers with nonpermissive values. (URL required) [hardened_site]
    Note that GitHub and GitLab are known to meet this. Sites such as https://securityheaders.com/ can quickly check this. The key hardening headers are: Content Security Policy (CSP), HTTP Strict Transport Security (HSTS), X-Content-Type-Options (as "nosniff"), and X-Frame-Options. Fully static web sites with no ability to log in via the web pages could omit some hardening headers with less risk, but there's no reliable way to detect such sites, so we require these headers even if they are fully static sites.

  • Other security issues


    The project MUST have performed a security review within the last 5 years. This review MUST consider the security requirements and security boundary. [security_review]
    This MAY be done by the project members and/or an independent evaluation. This evaluation MAY be supported by static and dynamic analysis tools, but there also must be human review to identify problems (particularly in design) that tools cannot detect.


    Hardening mechanisms MUST be used in the software produced by the project so that software defects are less likely to result in security vulnerabilities. (URL required) [hardening]
    Hardening mechanisms may include HTTP headers like Content Security Policy (CSP), compiler flags to mitigate attacks (such as -fstack-protector), or compiler flags to eliminate undefined behavior. For our purposes least privilege is not considered a hardening mechanism (least privilege is important, but separate).

 Analysis 0/2

  • Dynamic code analysis


    The project MUST apply at least one dynamic analysis tool to any proposed major production release of the software produced by the project before its release. [dynamic_analysis]
    A dynamic analysis tool examines the software by executing it with specific inputs. For example, the project MAY use a fuzzing tool (e.g., American Fuzzy Lop) or a web application scanner (e.g., OWASP ZAP or w3af). In some cases the OSS-Fuzz project may be willing to apply fuzz testing to your project. For purposes of this criterion the dynamic analysis tool needs to vary the inputs in some way to look for various kinds of problems or be an automated test suite with at least 80% branch coverage. The Wikipedia page on dynamic analysis and the OWASP page on fuzzing identify some dynamic analysis tools. The analysis tool(s) MAY be focused on looking for security vulnerabilities, but this is not required.

    Warning: Requires lengthier justification.



    The project SHOULD include many run-time assertions in the software it produces and check those assertions during dynamic analysis. [dynamic_analysis_enable_assertions]
    This criterion does not suggest enabling assertions during production; that is entirely up to the project and its users to decide. This criterion's focus is instead to improve fault detection during dynamic analysis before deployment. Enabling assertions in production use is completely different from enabling assertions during dynamic analysis (such as testing). In some cases enabling assertions in production use is extremely unwise (especially in high-integrity components). There are many arguments against enabling assertions in production, e.g., libraries should not crash callers, their presence may cause rejection by app stores, and/or activating an assertion in production may expose private data such as private keys. Beware that in many Linux distributions NDEBUG is not defined, so C/C++ assert() will by default be enabled for production in those environments. It may be important to use a different assertion mechanism or defining NDEBUG for production in those environments.

    Warning: Requires lengthier justification.



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.