3 unstable releases

0.3.0 Sep 8, 2023
0.1.1 Aug 16, 2023
0.1.0 Aug 16, 2023

#1334 in Cryptography

Download history 420/week @ 2024-01-01 478/week @ 2024-01-08 473/week @ 2024-01-15 230/week @ 2024-01-22 110/week @ 2024-01-29 37/week @ 2024-02-05 213/week @ 2024-02-12 335/week @ 2024-02-19 749/week @ 2024-02-26 300/week @ 2024-03-04 464/week @ 2024-03-11 490/week @ 2024-03-18 479/week @ 2024-03-25 624/week @ 2024-04-01 3421/week @ 2024-04-08 7031/week @ 2024-04-15

11,568 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

~13MB
~336K SLoC