4 releases

0.3.1 May 2, 2024
0.3.0 Sep 8, 2023
0.1.1 Aug 16, 2023
0.1.0 Aug 16, 2023

#776 in Cryptography

Download history 8195/week @ 2024-11-16 6830/week @ 2024-11-23 7338/week @ 2024-11-30 8112/week @ 2024-12-07 7508/week @ 2024-12-14 3600/week @ 2024-12-21 4164/week @ 2024-12-28 10760/week @ 2025-01-04 34461/week @ 2025-01-11 9494/week @ 2025-01-18 7771/week @ 2025-01-25 9928/week @ 2025-02-01 89459/week @ 2025-02-08 92383/week @ 2025-02-15 113818/week @ 2025-02-22 113808/week @ 2025-03-01

411,321 downloads per month
Used in snowflake-api

Apache-2.0

15KB
95 lines

snowflake-jwt

Generates JWT token in Snowflake-compatible format, see Using Key Pair Authentication.

Can be used in order to run queries against SQL REST API.

Usage

[dependencies]
snowflake-jwt = "0.1.0"

Check examples for working programs using the library.

use anyhow::Result;
use std::fs;
use snowflake_jwt;

fn get_token(private_key_path: &str, account_identifier: &str, username: &str) -> Result<String> {
    let pem = fs::read_to_string(private_key_path)?;
    let full_identifier = format!("{}.{}", account_identifier, username);
    let jwt = snowflake_jwt::generate_jwt_token(&pem, &full_identifier)?;

    Ok(jwt)
}

lib.rs:

Custom serialization of OffsetDateTime to conform with the JWT spec (RFC 7519 section 2, "Numeric Date")

Dependencies

~5–15MB
~208K SLoC