Giter Site home page Giter Site logo

passage-rust's Introduction

Passage logo

Passage SDK for Rust

This crate provides a library for working with Passage, a modern passwordless authentication experience based on passkeys and magic links. This library currently implements a very small subset of the available Passage API endpoints.

At the moment, this SDK assists with server-side authentication.

Installation

cargo add passage-id

Example: validation of Passage JWTs

extern crate passage_id;
use crate::passage_id::Passage;

fn main() {
    // Your app id from https://console.passage.id/settings
    let app_id = "...";

    // Create an api key for your app at https://console.passage.id/settings/apikeys
    let api_key = "...";

    // Download your app's public jwk key from https://auth.passage.id/v1/apps/{app_id}/.well-known/jwks.json. Note this is a single key, not an array.
    let pub_key = r#"{
        "alg": "RS256",
        "kty": "RSA",
        "use": "sig",
        "n": "...",
        "e": "AQAB",
        "kid": "..."
      }"#;

    // The Passage struct can be created once, stored/cached, and reused across multiple requests.
    let passage = Passage::new(String::from(app_id), String::from(api_key), String::from(pub_key));

    // If you are using an Element, the Passage JWT will be sent to your application via a cookie with the key `psg_auth_token`
    let psg_auth_token = "...";
    let result = passage.authenticate_token(psg_auth_token);

    match result {
        Ok(passage_user_id) => println!(
            "Passage JWT is valid. passage_user_id=<{}>",
            passage_user_id
        ),
        Err(err) => {
            println!("Auth error: {:?}", err);
        }
    }
}

passage-rust's People

Contributors

dteare avatar robyoder avatar

Watchers

 avatar  avatar

Forkers

dteare

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.