Skip to content

Commit 3af6805

Browse files
committed
Add private-key-knowledge VSS authentication
In PR lightningdevkit/ldk-node#755, we shipped a VSS authentication scheme in ldk-node that grants access to data stored in VSS based on the knowledge of a private key. This authentication scheme is the default method of authentication to VSS server in ldk-node. Here we wire up this authentication scheme to the public API of this crate. With this commit, if only the `--vss-url` argument is passed to the cli example, with no other VSS arguments, sigs auth is now used. VSS server default builds expect this authentication mechanism, and it works out of the box, so it is very demo-friendly. First launch VSS server: `cargo run -- server/vss-server-config.toml` then launch the cli example against VSS: `cargo run -- --vss-url http://127.0.0.1:8080/vss` Commit written with codex.
1 parent 9ae182c commit 3af6805

4 files changed

Lines changed: 29 additions & 3 deletions

File tree

bindings/swift/Sources/OrangeSDK/OrangeSDK.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5296,6 +5296,7 @@ public enum VssAuth {
52965296
*/
52975297
case fixedHeaders([String: String]
52985298
)
5299+
case sigsAuth
52995300
}
53005301

53015302

@@ -5319,6 +5320,8 @@ public struct FfiConverterTypeVssAuth: FfiConverterRustBuffer {
53195320
case 2: return .fixedHeaders(try FfiConverterDictionaryStringString.read(from: &buf)
53205321
)
53215322

5323+
case 3: return .sigsAuth
5324+
53225325
default: throw UniffiInternalError.unexpectedEnumCase
53235326
}
53245327
}
@@ -5336,6 +5339,10 @@ public struct FfiConverterTypeVssAuth: FfiConverterRustBuffer {
53365339
writeInt(&buf, Int32(2))
53375340
FfiConverterDictionaryStringString.write(v1, into: &buf)
53385341

5342+
5343+
case .sigsAuth:
5344+
writeInt(&buf, Int32(3))
5345+
53395346
}
53405347
}
53415348
}

examples/cli/src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ struct Cli {
3838
/// local SQLite for all wallet persistence.
3939
#[arg(long)]
4040
vss_url: Option<String>,
41-
/// LNURL-auth server URL for VSS authentication. When omitted, fixed
42-
/// headers (possibly empty) are used instead.
41+
/// LNURL-auth server URL for VSS authentication. When omitted, VSS uses
42+
/// sigs auth unless fixed headers are provided. Sigs auth requires no
43+
/// setup on VSS server; it works out of the box.
4344
#[arg(long, requires = "vss_url")]
4445
vss_lnurl_auth_url: Option<String>,
4546
/// Fixed HTTP header to attach to every VSS request, in `Key:Value` form.
@@ -62,6 +63,7 @@ fn build_storage_config(cli: &Cli, storage_path: &str) -> StorageConfig {
6263
let store_id = "orange-cli".to_string();
6364
let headers = match cli.vss_lnurl_auth_url.clone() {
6465
Some(url) => VssAuth::LNURLAuthServer(url),
66+
None if cli.vss_headers.is_empty() => VssAuth::SigsAuth,
6567
None => VssAuth::FixedHeaders(cli.vss_headers.iter().cloned().collect::<HashMap<_, _>>()),
6668
};
6769
println!(

orange-sdk/src/ffi/orange/config.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,21 @@ pub enum VssAuth {
7575
/// A fixed set of HTTP headers included as-is on every request made to
7676
/// VSS.
7777
FixedHeaders(HashMap<String, String>),
78+
/// Simple authentication scheme where access is granted by the knowledge of a private key.
79+
///
80+
/// There is no specific restriction of who is allowed to store data in VSS using this
81+
/// authentication scheme, only that each user is only allowed to store and access data for
82+
/// which they have a corresponding private key. Thus, you must ensure new user accounts are
83+
/// appropriately rate-limited or access to the VSS server is somehow limited.
84+
SigsAuth,
7885
}
7986

8087
impl From<VssAuth> for OrangeVssAuth {
8188
fn from(auth: VssAuth) -> Self {
8289
match auth {
8390
VssAuth::LNURLAuthServer(url) => OrangeVssAuth::LNURLAuthServer(url),
8491
VssAuth::FixedHeaders(headers) => OrangeVssAuth::FixedHeaders(headers),
92+
VssAuth::SigsAuth => OrangeVssAuth::SigsAuth,
8593
}
8694
}
8795
}
@@ -91,6 +99,7 @@ impl From<OrangeVssAuth> for VssAuth {
9199
match auth {
92100
OrangeVssAuth::LNURLAuthServer(url) => VssAuth::LNURLAuthServer(url),
93101
OrangeVssAuth::FixedHeaders(headers) => VssAuth::FixedHeaders(headers),
102+
OrangeVssAuth::SigsAuth => VssAuth::SigsAuth,
94103
}
95104
}
96105
}

orange-sdk/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ pub enum VssAuth {
189189
/// A fixed set of HTTP headers included as-is on every request made to
190190
/// VSS.
191191
FixedHeaders(HashMap<String, String>),
192+
/// Simple authentication scheme where access is granted by the knowledge of a private key.
193+
///
194+
/// There is no specific restriction of who is allowed to store data in VSS using this
195+
/// authentication scheme, only that each user is only allowed to store and access data for
196+
/// which they have a corresponding private key. Thus, you must ensure new user accounts are
197+
/// appropriately rate-limited or access to the VSS server is somehow limited.
198+
SigsAuth,
192199
}
193200

194201
/// Configuration for a [Versioned Storage Service (VSS)] backend.
@@ -581,10 +588,11 @@ impl Wallet {
581588
config.network,
582589
);
583590
let vss_store = match &vss_config.headers {
584-
VssAuth::FixedHeaders(h) => builder.build_with_fixed_headers(h.clone())?,
585591
VssAuth::LNURLAuthServer(url) => {
586592
builder.build_with_lnurl(url.clone(), HashMap::new())?
587593
},
594+
VssAuth::FixedHeaders(h) => builder.build_with_fixed_headers(h.clone())?,
595+
VssAuth::SigsAuth => builder.build_with_sigs_auth(HashMap::new())?,
588596
};
589597
Arc::new(vss_store)
590598
},

0 commit comments

Comments
 (0)