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

#269 in Cryptography

Download history 95/week @ 2024-01-24 74/week @ 2024-01-31 93/week @ 2024-02-07 184/week @ 2024-02-14 543/week @ 2024-02-21 628/week @ 2024-02-28 292/week @ 2024-03-06 581/week @ 2024-03-13 427/week @ 2024-03-20 565/week @ 2024-03-27 983/week @ 2024-04-03 5454/week @ 2024-04-10 7137/week @ 2024-04-17 7187/week @ 2024-04-24 6736/week @ 2024-05-01 8180/week @ 2024-05-08

30,871 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
~195K SLoC