Crates.io | scylla-aws-keyspaces-authenticator |
lib.rs | scylla-aws-keyspaces-authenticator |
version | 0.1.0 |
source | src |
created_at | 2022-12-17 18:02:17.451286 |
updated_at | 2022-12-17 18:02:17.451286 |
description | This crate provides a simple to use AuthenticatorProvider implementation for scylla crate that works with AWS KeySpaces for Cassandra service. |
homepage | https://github.com/infr-dev/scylla-aws-keyspaces-authenticator |
repository | https://github.com/infr-dev/scylla-aws-keyspaces-authenticator |
max_upload_size | |
id | 739979 |
size | 65,719 |
This crate provides a simple to use AuthenticatorProvider implementation for scylla crate that works with AWS KeySpaces for Cassandra service.
use scylla::SessionBuilder;
use scylla_aws_keyspaces_authenticator::AwsKeyspacesAuthenticator;
use openssl::ssl::*;
let config = aws_config::from_env().region("us-east-1").load().await;
// One-liner to enable AWS Sigv4 authentication for Scylla driver for Rust:
let authenticator = AwsKeyspacesAuthenticator::new(config);
// Some SSL setup
let mut ssl_context = SslContextBuilder::new(SslMethod::tls()).unwrap();
ssl_context.set_certificate_file("./examples/aws-keyspaces-cert.pem", SslFiletype::PEM).unwrap();
ssl_context.set_verify(SslVerifyMode::NONE);
// Create session
let session = SessionBuilder::new()
.known_node("cassandra.us-east-1.amazonaws.com:9142")
.authenticator_provider(authenticator)
.ssl_context(Some(ssl_context.build()))
.build()
.await
.unwrap();
// Run query
let results = session.query("SELECT * from example.example_table;", &[]).await.unwrap();
println!("{:?}", results);