Skip to content

Commit

Permalink
feat: Update base64 dependency (#108)
Browse files Browse the repository at this point in the history
- Fix docker-compose to use soft and hard ulimits
- Update Auth default to fix clippy
  • Loading branch information
vihu committed Aug 3, 2023
1 parent 420dcb1 commit 690a0a3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
18 changes: 12 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ arango3_7 = [ ]

[dependencies]
async-trait = "0.1"
base64 = "0.13"
base64 = "0.21.2"
http = "0.2"
log = "0.4"
maybe-async = "0.2"
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ services:
environment:
- ARANGO_STORAGE_ENGINE=rocksdb
- ARANGO_ROOT_PASSWORD=KWNngteTps7XjrNv
ulimits:
nofile:
soft: 65536
hard: 65536

volumes:
data_arangors:
Expand Down
9 changes: 2 additions & 7 deletions src/connection/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,17 @@
/// let no_auth = Auth::None;
/// let no_auth = Auth::default();
/// ```
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub(crate) enum Auth<'a> {
/// Basic auth
Basic(Credential<'a>),
/// JSON Web Token (JWT) auth
Jwt(Credential<'a>),
/// no auth
#[default]
None,
}

impl<'a> Default for Auth<'a> {
fn default() -> Auth<'static> {
Auth::None
}
}

impl<'a> Auth<'a> {
pub fn basic(username: &'a str, password: &'a str) -> Auth<'a> {
Auth::Basic(Credential { username, password })
Expand Down
4 changes: 3 additions & 1 deletion src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

use std::{collections::HashMap, fmt::Debug, sync::Arc};

use base64::{engine::general_purpose, Engine as _};
use http::header::{HeaderMap, AUTHORIZATION, SERVER};
use log::{debug, trace};
use maybe_async::maybe_async;
Expand Down Expand Up @@ -241,7 +242,8 @@ impl<C: ClientExt> GenericConnection<C, Normal> {
Auth::Basic(cred) => {
username = String::from(cred.username);

let token = base64::encode(&format!("{}:{}", cred.username, cred.password));
let token = general_purpose::STANDARD_NO_PAD
.encode(format!("{}:{}", cred.username, cred.password));
Some(format!("Basic {}", token))
}
Auth::Jwt(cred) => {
Expand Down

0 comments on commit 690a0a3

Please sign in to comment.