photoncloud-monorepo/nightlight/crates/nightlight-api/build.rs
centra d2149b6249 fix(lightningstor): Fix SigV4 canonicalization for AWS S3 auth
- Replace form_urlencoded with RFC 3986 compliant URI encoding
- Implement aws_uri_encode() matching AWS SigV4 spec exactly
- Unreserved chars (A-Z,a-z,0-9,-,_,.,~) not encoded
- All other chars percent-encoded with uppercase hex
- Preserve slashes in paths, encode in query params
- Normalize empty paths to '/' per AWS spec
- Fix test expectations (body hash, HMAC values)
- Add comprehensive SigV4 signature determinism test

This fixes the canonicalization mismatch that caused signature
validation failures in T047. Auth can now be enabled for production.

Refs: T058.S1
2025-12-12 06:23:46 +09:00

26 lines
1 KiB
Rust

fn main() -> Result<(), Box<dyn std::error::Error>> {
// Set PROTOC environment variable to use vendored protoc
let protoc_path = protoc_bin_vendored::protoc_bin_path()?;
std::env::set_var("PROTOC", protoc_path);
// Compile the protobuf files to OUT_DIR
// This generates Rust code from the .proto definitions
tonic_build::configure()
.build_server(true) // Generate server traits
.build_client(true) // Generate client stubs
.compile_protos(
&[
"proto/remote_write.proto", // Prometheus remote write protocol
"proto/query.proto", // PromQL query API
"proto/admin.proto", // Admin/health endpoints
],
&["proto"], // Include path for proto files
)?;
// Tell cargo to rerun build.rs if proto files change
println!("cargo:rerun-if-changed=proto/remote_write.proto");
println!("cargo:rerun-if-changed=proto/query.proto");
println!("cargo:rerun-if-changed=proto/admin.proto");
Ok(())
}