Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ By far most changes relate to `atomic-server`, so if not specified, assume the c
**Changes to JS assets (including the front-end and JS libraries) are not shown here**, but in [`/browser/CHANGELOG`](/browser/CHANGELOG.md).
See [STATUS.md](server/STATUS.md) to learn more about which features will remain stable.

## [UNRELEASED]

- Speed up Commits by bundling DB transactions #297
- Introduce `Db::apply_transaction` and `Storelike::apply_commit`
- Deprecate `add_atom_to_index` and `remove_atom_from_index` as public methods.

## [v0.39.0] - 2024-08-21

- The download endpoint can now optimize images on the fly. This is controlled via query parameters. #257
Expand Down
8 changes: 0 additions & 8 deletions lib/benches/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ fn random_resource(atom: &Atom) -> Resource {
fn criterion_benchmark(c: &mut Criterion) {
let store = Db::init_temp("bench").unwrap();

c.bench_function("add_atom_to_index", |b| {
b.iter(|| {
let atom = random_atom();
let resource = random_resource(&random_atom());
store.add_atom_to_index(&atom, &resource).unwrap();
})
});

c.bench_function("add_resource", |b| {
b.iter(|| {
let resource = random_resource(&random_atom());
Expand Down
9 changes: 6 additions & 3 deletions lib/src/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

use crate::{
agents::{decode_base64, ForAgent},
commit::check_timestamp,
errors::AtomicResult,
urls, Storelike,
urls,
utils::check_timestamp_in_past,
Storelike,
};

/// Set of values extracted from the request.
Expand Down Expand Up @@ -47,6 +48,8 @@ pub fn check_auth_signature(subject: &str, auth_header: &AuthValues) -> AtomicRe
Ok(())
}

const ACCEPTABLE_TIME_DIFFERENCE: i64 = 10000;

/// Get the Agent's subject from [AuthValues]
/// Checks if the auth headers are correct, whether signature matches the public key, whether the timestamp is valid.
/// by default, returns the public agent
Expand All @@ -60,7 +63,7 @@ pub fn get_agent_from_auth_values_and_check(
check_auth_signature(&auth_vals.requested_subject, &auth_vals)
.map_err(|e| format!("Error checking authentication headers. {}", e))?;
// check if the timestamp is valid
check_timestamp(auth_vals.timestamp)?;
check_timestamp_in_past(auth_vals.timestamp, ACCEPTABLE_TIME_DIFFERENCE)?;
// check if the public key belongs to the agent
let found_public_key = store.get_value(&auth_vals.agent_subject, urls::PUBLIC_KEY)?;
if found_public_key.to_string() != auth_vals.public_key {
Expand Down
Loading