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
1,541 changes: 840 additions & 701 deletions Cargo.lock

Large diffs are not rendered by default.

26 changes: 17 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "iroh-auth"
version = "0.1.4"
version = "0.2.0-pre.1"
edition = "2021"
authors = ["rustonbsd <rustonbsd@mailfence.com>"]
description = "Authentication middleware for iroh"
Expand All @@ -12,27 +12,35 @@ categories = ["network-programming"]


[dependencies]
iroh = { version = "0.97" }
iroh = { version = "1.0.0-rc.1" }
spake2 = { version = "0.4" }
hkdf = { version = "0.12" }
secrecy = { version = "0.10" }
sha2 = { version = "0.10" }
subtle = { version = "2.6" }
rand = { version = "0.9" }
rand = { version = "0.10" }
n0-future = { version = "0.3" }
n0-watcher = { version = "0.6" }
tracing = { version = "0.1" }
tokio = { version = "1" }
tokio = { version = "1", features = [
"macros",
"rt-multi-thread",
"sync",
"time",
] }
lru = { version = "0.18" }

iroh-gossip = { version = "0.97", optional = true }
anyhow = { version = "1", optional = true}
tracing-subscriber = { version = "0.3", features = ["env-filter"], optional = true }
iroh-gossip = { version = "0.100", optional = true }
anyhow = { version = "1", optional = true }
tracing-subscriber = { version = "0.3", features = [
"env-filter",
], optional = true }

[features]
gossip-example = ["iroh-gossip", "anyhow", "tracing-subscriber"]
gossip-example = ["iroh-gossip", "anyhow", "tracing-subscriber", "tokio/signal"]
default = []

[[example]]
name = "gossip"
path = "examples/gossip.rs"
required-features = ["gossip-example"]
required-features = ["gossip-example"]
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Add this to your `Cargo.toml`:

```toml
[dependencies]
iroh = "0.96"
iroh-auth = "0.1"
iroh = "0.98"
iroh-auth = "0.2.0-pre.1"
```

## Usage
Expand All @@ -44,14 +44,14 @@ async fn main() -> Result<(), String> {
let auth = Authenticator::new("my-super-secret-password");

// 2. Build the endpoint with the auth hooks
let endpoint = Endpoint::builder()
let endpoint = Endpoint::builder(iroh::endpoint::presets::N0)
.hooks(auth.clone())
.bind()
.await.map_err(|e| e.to_string())?;

// 3. The authenticator needs a reference to the bound endpoint
// to initiate authentication handshakes.
auth.set_endpoint(&endpoint);
auth.set_endpoint(&endpoint).await;

// 4. Register the auth protocol handler
let router = Router::builder(endpoint)
Expand All @@ -78,7 +78,7 @@ sequenceDiagram

Client->>Server: 1. App Connection Request
activate Server
Note right of Server: Paused (Waiting for Auth)
Note right of Server: Paused (Waiting for Auth)

rect rgb(225, 255, 225)
Note over Client, Server: 2. Authentication (Background)
Expand All @@ -87,11 +87,11 @@ sequenceDiagram

alt Success
Server->>Server: Verify Secret (OK)
Note right of Server: Resumed
Note right of Server: Resumed
Server-->>Client: 3. App Connection Accepted
else Failure
Server->>Server: Verify Secret (Fail)
Note right of Server: Rejected
Note right of Server: Rejected
Server-->>Client: 3. Connection Closed
end
deactivate Server
Expand Down
2 changes: 1 addition & 1 deletion examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async fn main() -> Result<(), String> {

// 3. The authenticator needs a reference to the bound endpoint
// to initiate authentication handshakes.
auth.set_endpoint(&endpoint);
auth.set_endpoint(&endpoint).await;

// 4. Register the auth protocol handler
let router = Router::builder(endpoint)
Expand Down
4 changes: 2 additions & 2 deletions examples/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ async fn main() -> Result<(), String> {

// #1 Create Authenticator
let auth = Authenticator::new("my-secure-network-secret-12345");
let endpoint = Endpoint::builder()
let endpoint = Endpoint::builder(iroh::endpoint::presets::N0)
// #2 Add auth hooks
.hooks(auth.clone())
.bind()
.await
.map_err(|e| e.to_string())?;

// #3 Pass endpoint to the Authenticator for establishing auth connections
auth.set_endpoint(&endpoint);
auth.set_endpoint(&endpoint).await;

let gossip = Gossip::builder().spawn(endpoint.clone());

Expand Down
Loading
Loading