Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jw/custom headers in auth #206

Open
wants to merge 83 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
49f044f
wip - passing userauthcontext instead of http headers
Feb 29, 2024
5fece60
merged main
Mar 1, 2024
946c9ea
revert comment out
shopifyski Mar 1, 2024
ecf2389
fixed temp change
shopifyski Mar 1, 2024
9521d72
Merge branch 'main' into jw/changing-how-jwt-is-passed-around
shopifyski Mar 1, 2024
83e91ff
fixed failing tests
shopifyski Mar 1, 2024
b8bb476
next iteration of unit test fixing
shopifyski Mar 4, 2024
e322b1a
fixed remaining unit tests
shopifyski Mar 4, 2024
6b517ea
reverted debug
shopifyski Mar 4, 2024
e3bd67c
removed accidentally added file
shopifyski Mar 4, 2024
8f6b127
Merge branch 'main' into jw/changing-how-jwt-is-passed-around
shopifyski Mar 4, 2024
f038f39
moved str to userauthcontext conversion to from trait
shopifyski Mar 5, 2024
9bc376b
remove vague comment
shopifyski Mar 5, 2024
37c130f
cargo fmt
shopifyski Mar 5, 2024
b350ce5
cleaned up mod reimportss
shopifyski Mar 5, 2024
d3ccabc
refactored cryptic matching in replica_proxy
shopifyski Mar 6, 2024
9b353cd
marked potentially duplicate code with // todo dupe #auth
shopifyski Mar 6, 2024
e30d5a3
refactored context to custome errors
shopifyski Mar 6, 2024
cadf427
added a factory to produce empty UserAuthContext
shopifyski Mar 6, 2024
5077466
added constructors for UserAuthContext
shopifyski Mar 6, 2024
071dcf3
switched from try_into to using constructors
shopifyski Mar 6, 2024
9f94e4e
cargo fmt
shopifyski Mar 6, 2024
284b36f
added tests for failing cases in parsers
shopifyski Mar 7, 2024
d0ec05a
adding mamespace as param wip
shopifyski Mar 8, 2024
f716a28
cargo fmt
shopifyski Mar 8, 2024
843c9f7
added test for non-asci error
shopifyski Mar 8, 2024
5c79f33
Merge branch 'main' into jw/changing-how-jwt-is-passed-around
shopifyski Mar 8, 2024
1340d87
Merge branch 'jw/changing-how-jwt-is-passed-around' into jw/namespace…
shopifyski Mar 8, 2024
047823b
incremental changes to make namespace as param work
shopifyski Mar 8, 2024
d32bd5f
fixed failing test
shopifyski Mar 11, 2024
12df9f9
Merge branch 'jw/changing-how-jwt-is-passed-around' into jw/namespace…
shopifyski Mar 11, 2024
4125383
fixed log message
shopifyski Mar 13, 2024
37dc162
merged main
shopifyski Mar 13, 2024
3105025
removed unnecessary error mapping
shopifyski Mar 14, 2024
bccfe77
turned context to result
shopifyski Mar 14, 2024
37dc3af
removing dummy tokens from tests
shopifyski Mar 14, 2024
57861f6
cargo fmt + cleanup
shopifyski Mar 14, 2024
91bd024
Merge branch 'jw/changing-how-jwt-is-passed-around' into jw/namespace…
shopifyski Mar 14, 2024
91cc1fd
Merge branch 'main' into jw/namespace-passing-and-auth
shopifyski Mar 18, 2024
9df60da
namespace passing exammple
shopifyski Mar 18, 2024
9f97d3e
added namespace config for the example
shopifyski Mar 22, 2024
ce73236
Merge branch 'main' into jw/namespace-passing-and-auth
shopifyski Mar 22, 2024
d0a5646
remove unnecessary dummy token
shopifyski Mar 22, 2024
b9f10a7
reverting accidental commit
shopifyski Mar 22, 2024
1cb0ecd
wip
shopifyski Mar 27, 2024
3e7999a
wip
shopifyski Mar 27, 2024
844dd54
custom fields in auth context
shopifyski Mar 28, 2024
6afb112
fixed compilation errors, wip
shopifyski Mar 28, 2024
7f8b0b4
refactored auth api with on demand headers
shopifyski Mar 29, 2024
6aba6e5
removing optionality of UserAuthContext
shopifyski Mar 29, 2024
1f2de7e
clean up dead code
shopifyski Mar 29, 2024
e4a87fa
bottomless: emit restored snapshot for waiters (#1252)
LucioFranco Mar 22, 2024
6d263cf
fix conn upgrade lock (#1244)
MarinPostma Mar 22, 2024
ae54987
prevent primary to remove itself in case of load error (#1253)
MarinPostma Mar 23, 2024
60e61d5
server: fix interactive txn schema panic (#1250)
LucioFranco Mar 25, 2024
1bd1414
libsql-ffi: Fix sqlite3mc build output directory (#1234)
penberg Mar 25, 2024
a547163
server: add shutdown timeout (#1258)
LucioFranco Mar 25, 2024
b476c20
server: release v0.24.4 (#1259)
LucioFranco Mar 25, 2024
2970ec9
server: allow explain queries without bind parameters (#1256)
Mar 25, 2024
c014a14
add libsql-hrana crate (#1260)
LucioFranco Mar 25, 2024
862caf7
add windows ci (#1263)
LucioFranco Mar 26, 2024
f1caad3
libsql: prepare v0.3.1 release (#1264)
LucioFranco Mar 26, 2024
a0449b3
libsql-hrana: add description (#1265)
LucioFranco Mar 26, 2024
eb00b3b
deduplicated handling of hrana hello and repreated hello. Code is ful…
shopifyski Mar 27, 2024
ded73df
fixed early return
shopifyski Mar 27, 2024
7d09d05
lazy unwrapping
shopifyski Mar 27, 2024
79505c1
made session fields private again
shopifyski Mar 28, 2024
8c0d880
fmt
shopifyski Mar 28, 2024
6ebd029
cleaned up nesting in conn
shopifyski Mar 28, 2024
bff68f9
fmt
shopifyski Mar 29, 2024
cf54127
merge upstream pr
shopifyski Mar 29, 2024
b156cc5
Merge branch 'main' into jw/custom-headers-in-auth
shopifyski Mar 29, 2024
021d21b
deduplicated handling of hrana hello and repreated hello. Code is ful…
shopifyski Mar 27, 2024
931006a
made session fields private again
shopifyski Mar 28, 2024
f23d0e4
fmt
shopifyski Mar 28, 2024
003af3c
libsql: add 5s keepalive for clients (#1251)
LucioFranco Mar 30, 2024
7110953
Stop expiring connections in replication hyper client (#1275)
haaawk Apr 1, 2024
46d2407
Add more logging in case snapshots fail (#1270)
Apr 1, 2024
8fbdb3f
server: add embedded replica stats test for replica (#1278)
LucioFranco Apr 1, 2024
405e1d5
libsql-ffi: Make CC and CXX configurable (#1257)
penberg Apr 2, 2024
752e692
libsql: fix malformed db and add test (#1217)
LucioFranco Apr 4, 2024
d32ff12
refactored ns selection to be more expressive
shopifyski Apr 8, 2024
1f462cd
narrowed the type constraints for namespace arg
shopifyski Apr 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions libsql-ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ fn copy_multiple_ciphers(out_dir: &str, out_path: &Path) {
}

fn build_multiple_ciphers(out_path: &Path) {
let target = env::var("TARGET").unwrap();
let bindgen_rs_path = if cfg!(feature = "session") {
"bundled/bindings/session_bindgen.rs"
} else {
Expand Down Expand Up @@ -298,12 +299,8 @@ fn build_multiple_ciphers(out_path: &Path) {

let mut cmake_opts: Vec<&str> = vec![];

let cargo_build_target = env::var("CARGO_BUILD_TARGET").unwrap_or_default();
let cross_cc_var_name = format!("CC_{}", cargo_build_target.replace("-", "_"));
let cross_cc = env::var(&cross_cc_var_name).ok();

let cross_cxx_var_name = format!("CXX_{}", cargo_build_target.replace("-", "_"));
let cross_cxx = env::var(&cross_cxx_var_name).ok();
let cc = env("CC");
let cxx = env("CXX");

let toolchain_path = sqlite3mc_build_dir.join("toolchain.cmake");
let cmake_toolchain_opt = format!("-DCMAKE_TOOLCHAIN_FILE=toolchain.cmake");
Expand All @@ -315,20 +312,22 @@ fn build_multiple_ciphers(out_path: &Path) {
.open(toolchain_path.clone())
.unwrap();

if let Some(ref cc) = cross_cc {
if let Some(ref cc) = cc {
let cc = cc.clone().into_string().unwrap();
if cc.contains("aarch64") && cc.contains("linux") {
cmake_opts.push(&cmake_toolchain_opt);
writeln!(toolchain_file, "set(CMAKE_SYSTEM_NAME \"Linux\")").unwrap();
writeln!(toolchain_file, "set(CMAKE_SYSTEM_PROCESSOR \"arm64\")").unwrap();
}
}
if let Some(cc) = cross_cc {
if let Some(cc) = cc {
let cc = cc.into_string().unwrap();
writeln!(toolchain_file, "set(CMAKE_C_COMPILER {})", cc).unwrap();
}
if let Some(cxx) = cross_cxx {
if let Some(cxx) = cxx {
let cxx = cxx.into_string().unwrap();
writeln!(toolchain_file, "set(CMAKE_CXX_COMPILER {})", cxx).unwrap();
}

cmake_opts.push("-DCMAKE_BUILD_TYPE=Release");
cmake_opts.push("-DSQLITE3MC_STATIC=ON");
cmake_opts.push("-DCODEC_TYPE=AES256");
Expand All @@ -340,7 +339,7 @@ fn build_multiple_ciphers(out_path: &Path) {
cmake_opts.push("-DSQLITE_USE_URI=ON");
cmake_opts.push("-DCMAKE_POSITION_INDEPENDENT_CODE=ON");

if cargo_build_target.contains("musl") {
if target.contains("musl") {
cmake_opts.push("-DCMAKE_C_FLAGS=\"-U_FORTIFY_SOURCE\"");
cmake_opts.push("-DCMAKE_CXX_FLAGS=\"-U_FORTIFY_SOURCE\"");
}
Expand Down
36 changes: 32 additions & 4 deletions libsql-replication/src/injector/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::VecDeque;
use std::path::Path;
use std::sync::Arc;
use std::{collections::VecDeque, path::PathBuf};

use parking_lot::Mutex;
use rusqlite::OpenFlags;
Expand Down Expand Up @@ -33,6 +33,11 @@ pub struct Injector {
// connection must be dropped before the hook context
connection: Arc<Mutex<libsql_sys::Connection<InjectorWal>>>,
biggest_uncommitted_seen: FrameNo,

// Connection config items used to recreate the injection connection
path: PathBuf,
encryption_config: Option<libsql_sys::EncryptionConfig>,
auto_checkpoint: u32,
}

/// Methods from this trait are called before and after performing a frame injection.
Expand All @@ -46,17 +51,19 @@ impl Injector {
auto_checkpoint: u32,
encryption_config: Option<libsql_sys::EncryptionConfig>,
) -> Result<Self, Error> {
let path = path.as_ref().to_path_buf();

let buffer = FrameBuffer::default();
let wal_manager = InjectorWalManager::new(buffer.clone());
let connection = libsql_sys::Connection::open(
path,
&path,
OpenFlags::SQLITE_OPEN_READ_WRITE
| OpenFlags::SQLITE_OPEN_CREATE
| OpenFlags::SQLITE_OPEN_URI
| OpenFlags::SQLITE_OPEN_NO_MUTEX,
wal_manager,
auto_checkpoint,
encryption_config,
encryption_config.clone(),
)?;

Ok(Self {
Expand All @@ -65,6 +72,10 @@ impl Injector {
capacity,
connection: Arc::new(Mutex::new(connection)),
biggest_uncommitted_seen: 0,

path,
encryption_config,
auto_checkpoint,
})
}

Expand Down Expand Up @@ -161,7 +172,24 @@ impl Injector {
}

fn begin_txn(&mut self) -> Result<(), Error> {
let conn = self.connection.lock();
let mut conn = self.connection.lock();

{
let wal_manager = InjectorWalManager::new(self.buffer.clone());
let new_conn = libsql_sys::Connection::open(
&self.path,
OpenFlags::SQLITE_OPEN_READ_WRITE
| OpenFlags::SQLITE_OPEN_CREATE
| OpenFlags::SQLITE_OPEN_URI
| OpenFlags::SQLITE_OPEN_NO_MUTEX,
wal_manager,
self.auto_checkpoint,
self.encryption_config.clone(),
)?;

let _ = std::mem::replace(&mut *conn, new_conn);
}

conn.pragma_update(None, "writable_schema", "true")?;

let mut stmt = conn.prepare_cached("BEGIN IMMEDIATE")?;
Expand Down
Loading