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

#508 in Cryptography

Download history 6931/week @ 2024-07-20 7096/week @ 2024-07-27 5506/week @ 2024-08-03 6511/week @ 2024-08-10 7011/week @ 2024-08-17 6671/week @ 2024-08-24 9582/week @ 2024-08-31 7852/week @ 2024-09-07 7788/week @ 2024-09-14 8148/week @ 2024-09-21 10142/week @ 2024-09-28 10411/week @ 2024-10-05 10276/week @ 2024-10-12 11808/week @ 2024-10-19 10213/week @ 2024-10-26 5746/week @ 2024-11-02

39,781 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–14MB
~197K SLoC