Skip to content

Commit 2f60ea3

Browse files
authored
Merge pull request #48 from junkurihara/develop
0.3.0
2 parents cb030b5 + b2e2b0f commit 2f60ea3

34 files changed

+717
-159
lines changed

.github/workflows/release_docker.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050

5151
- name: Release Build and push x86_64
5252
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref == 'develop' && github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true }}
53-
uses: docker/build-push-action@v5
53+
uses: docker/build-push-action@v6
5454
with:
5555
context: .
5656
push: true
@@ -64,7 +64,7 @@ jobs:
6464

6565
- name: Nightly build and push x86_64
6666
if: ${{ (github.ref_name == 'develop') && (github.event_name == 'push') }}
67-
uses: docker/build-push-action@v5
67+
uses: docker/build-push-action@v6
6868
with:
6969
context: .
7070
push: true
@@ -78,7 +78,7 @@ jobs:
7878

7979
- name: Unstable build and push x86_64 for 'feat/*' branches (for development purposes)
8080
if: ${{ startsWith(github.ref_name, 'feat/') && (github.event_name == 'push') }}
81-
uses: docker/build-push-action@v5
81+
uses: docker/build-push-action@v6
8282
with:
8383
context: .
8484
push: true

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace.package]
2-
version = "0.2.0"
2+
version = "0.3.0"
33
authors = ["Jun Kurihara"]
44
homepage = "https://github.com/junkurihara/modoh-server"
55
repository = "https://github.com/junkurihara/modoh-server"

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Options:
7474
-t, --otel-trace Enable opentelemetry for trace. Unless explicitly specified with '-e', collector endpoint is 'http://localhost:4317'.
7575
-m, --otel-metrics Enable opentelemetry for metrics. Unless explicitly specified with '-e', collector endpoint is 'http://localhost:4317'.
7676
-e, --otlp-endpoint <ENDPOINT_URL> Opentelemetry collector endpoint url connected via gRPC
77+
-q, --qrlog <PATH> Enable query-response logging. Unless specified, it is disabled.
7778
-h, --help Print help
7879
-V, --version Print version
7980
```
@@ -224,7 +225,7 @@ For the secure deployment of `modoh-server`, the access control mechanisms shoul
224225

225226
### Client Authentication using Bearer Token
226227

227-
For the client authentication, we can use the Bearer token in HTTP Authorization header, which is issued by [`rust-token-server`](https://github.com/junkurihara/rust-token-server) in the context of OpenID Connect. The authentication through the token validation is configured in the `[validation]` directive in `config.toml` as follows.
228+
For the client authentication, we can use the Bearer token in HTTP Authorization header, which is issued by [`rust-token-server`](https://github.com/junkurihara/rust-token-server) in the form of **OpenID Connect ID Token** or **Anonymous Token based on the blind RSA signatures ([RFC9474](https://www.rfc-editor.org/rfc/rfc9474.html))**. The authentication through the token validation is configured in the `[validation]` directive in `config.toml` as follows.
228229

229230
```toml
230231
## Validation of source, typically user clients, using Id token
@@ -243,7 +244,7 @@ token_issuer = "https://example.com/v1.0"
243244
client_ids = ["client_id_1", "client_id_2"]
244245
```
245246

246-
`modoh-server` allows multiple `[[validation.token]]` directives to accepts multiple clients authorized under various authorities. `modoh-server` periodically fetches their validation keys (public keys) through the token APIs' `jwks` endpoints, and concurrently verifies a request with the retrieved keys.
247+
`modoh-server` allows multiple `[[validation.token]]` directives to accepts multiple clients authorized under various authorities. `modoh-server` periodically fetches their validation keys (public keys) through the token APIs' `jwks` (for ID tokens) and `blindjwks` (for anonymous token) endpoints, and concurrently verifies a request with the retrieved keys.
247248

248249
Note that *when the bearer token does not exist in the HTTP request header, the request filtering based on the token validation is always bypassed*. This is because requests not from clients but from other relays have no such token in their header [^1]. Thus, *you should employ the source IP filtering mechanism for pre-authorized relays simultaneously with token validation.*
249250

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ RUN apt-get update && apt-get install -qy --no-install-recommends $BUILD_DEPS &&
2222
curl -sSf https://sh.rustup.rs | bash -s -- -y --default-toolchain stable && \
2323
export PATH="$HOME/.cargo/bin:$PATH" && \
2424
echo "Building Mutualized Oblivious DNS relay and target from source" && \
25-
cargo build --release --no-default-features --features=otel-full,otel-evil-trace --package modoh-server && \
25+
cargo build --release --no-default-features --features=otel-full,otel-evil-trace,qrlog --package modoh-server && \
2626
strip --strip-all /tmp/target/release/modoh-server
2727

2828
########################################

docker/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ We have several container-specific environment variables, which doesn't relates
1111
- `LOG_TO_FILE=true|false` (default: `false`): Enable logging to the log file `/modoh/log/modoh-server.log` using `logrotate`. You should mount `/modoh/log` via docker volume option if enabled. The log dir and file will be owned by the `HOST_USER` with `HOST_UID:HOST_GID` on the host machine. Hence, `HOST_USER`, `HOST_UID` and `HOST_GID` should be the same as ones of the user who executes the `modoh-server` container on the host.
1212
- `DISABLE_OTEL`: If explicitly set to `true`, `--trace` and `--metrics` are disabled in the execute option. (default: `false`)
1313
- `OTEL_ENDPOINT`: Set the gRPC endpoint of `opentelemetry-collector`. (default: `http://localhost:4317` but no collector is contained in the `modoh-server` docker container.)
14+
- `ENABLE_QRLOG`: If explicitly set to `true`, query-response logging is enabled in the `modoh-server`. (default: `false`) The log file will be `/modoh/log/qrlog.log` in the container. Note that the log rotation is set as the `modoh-server` system log.
1415

1516
See [`./docker-compose.yml`](./docker-compose.yml) for the detailed configuration of the above environment variables.
1617

docker/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ services:
2121
# - WATCH=true
2222
# - DISABLE_OTEL=true # opentelemetry is disabled if DISABLE_OTEL=true (default: false)
2323
- OTLP_ENDPOINT=http://otel-collector:4317 # opentelemetry endpoint (default: http://localhost:4317)
24+
# - ENABLE_QRLOG=true # qrlog is enabled if ENABLE_QRLOG is set. Record in `/modoh/log/qrlog.log` [default=false]
2425
tty: false
2526
privileged: true
2627
volumes:

docker/entrypoint.sh

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ CONFIG_FILE=/etc/modoh-server.toml
1313
CONFIG_DIR=/modoh/config
1414
CONFIG_FILE_IN_DIR=${CONFIG_FILENAME:-modoh-server.toml}
1515

16+
QRLOG_FILE=${LOG_DIR}/qrlog.log
17+
QRLOGGING=${ENABLE_QRLOG:-false}
18+
1619
#######################################
1720
# Setup logrotate
1821
function setup_logrotate () {
@@ -43,7 +46,8 @@ include /etc/logrotate.d
4346
# system-specific logs may be also be configured here.
4447
EOF
4548

46-
cat > /etc/logrotate.d/modoh-server.conf << EOF
49+
if "${LOGGING}"; then
50+
cat > /etc/logrotate.d/modoh-server.conf << EOF
4751
${LOG_FILE} {
4852
dateext
4953
daily
@@ -58,6 +62,25 @@ ${LOG_FILE} {
5862
su ${USER} ${USER}
5963
}
6064
EOF
65+
fi
66+
67+
if "${QRLOGGING}"; then
68+
cat > /etc/logrotate.d/qrlog.conf << EOF
69+
${QRLOG_FILE} {
70+
dateext
71+
daily
72+
missingok
73+
rotate ${LOG_NUM}
74+
notifempty
75+
compress
76+
delaycompress
77+
dateformat -%Y-%m-%d-%s
78+
size ${LOG_SIZE}
79+
copytruncate
80+
su ${USER} ${USER}
81+
}
82+
EOF
83+
fi
6184
}
6285

6386
#######################################
@@ -71,7 +94,7 @@ function setup_ubuntu () {
7194
fi
7295

7396
# for crontab when logging
74-
if "${LOGGING}"; then
97+
if ${LOGGING} || ${QRLOGGING} ; then
7598
# Set up logrotate
7699
setup_logrotate
77100

@@ -95,7 +118,7 @@ function setup_alpine () {
95118
fi
96119

97120
# for crontab when logging
98-
if "${LOGGING}"; then
121+
if ${LOGGING} || ${QRLOGGING} ; then
99122
# Set up logrotate
100123
setup_logrotate
101124

docker/run.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env sh
22
CONFIG_FILE=/etc/modoh-server.toml
33
DEFAULT_OTLP_ENDPOINT=http://localhost:4317
4+
QRLOG_FILE=/modoh/log/qrlog.log
45

56
# debug level logging
67
if [ -z $LOG_LEVEL ]; then
@@ -40,8 +41,19 @@ else
4041
OTEL_ARG="--otel-trace --otel-metrics --otlp-endpoint ${OTLP_ENDPOINT}"
4142
fi
4243

44+
# query-response logging
45+
QRLOG_ARG=""
46+
if [ -z $ENABLE_QRLOG ]; then
47+
ENABLE_QRLOG=false
48+
fi
49+
if $ENABLE_QRLOG ; then
50+
echo "modoh-server: Query-Response logging enabled with file ${QRLOG_FILE}"
51+
QRLOG_ARG="--qrlog ${QRLOG_FILE}"
52+
fi
53+
54+
4355
if $WATCH ; then
44-
RUST_LOG=${LOG_LEVEL} /modoh/bin/modoh-server --config ${CONFIG_FILE} -w ${OTEL_ARG}
56+
RUST_LOG=${LOG_LEVEL} /modoh/bin/modoh-server --config ${CONFIG_FILE} -w ${OTEL_ARG} ${QRLOG_ARG}
4557
else
46-
RUST_LOG=${LOG_LEVEL} /modoh/bin/modoh-server --config ${CONFIG_FILE} ${OTEL_ARG}
58+
RUST_LOG=${LOG_LEVEL} /modoh/bin/modoh-server --config ${CONFIG_FILE} ${OTEL_ARG} ${QRLOG_ARG}
4759
fi

httpsig-registry/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ edition.workspace = true
1313
publish.workspace = true
1414

1515
[dependencies]
16-
anyhow = { version = "1.0.83" }
17-
thiserror = { version = "1.0.60" }
18-
pulldown-cmark = { version = "0.10.3", default-features = false }
16+
anyhow = { version = "1.0.86" }
17+
thiserror = { version = "1.0.63" }
18+
pulldown-cmark = { version = "0.12.0", default-features = false }
1919
http = { version = "1.1.0" }
20-
indexmap = { version = "2.2.6" }
20+
indexmap = { version = "2.4.0" }
2121
minisign-verify = { version = "0.2.1" }
22-
reqwest = { version = "0.12.4", default-features = false, features = [
22+
reqwest = { version = "0.12.7", default-features = false, features = [
2323
"rustls-tls",
2424
"http2",
2525
"hickory-dns",
@@ -28,7 +28,7 @@ futures = { version = "0.3.30", default-features = false, features = [
2828
"std",
2929
"async-await",
3030
] }
31-
tokio = { version = "1.37.0", features = [
31+
tokio = { version = "1.39.3", features = [
3232
"net",
3333
"rt-multi-thread",
3434
"time",

httpsig-wire-proto/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ edition.workspace = true
1313
publish.workspace = true
1414

1515
[dependencies]
16-
anyhow = "1.0.83"
17-
thiserror = "1.0.60"
16+
anyhow = "1.0.86"
17+
thiserror = "1.0.63"
1818
rand = "0.8.5"
19-
hpke = "0.11.0"
20-
bytes = "1.6.0"
19+
hpke = "0.12.0"
20+
bytes = "1.7.1"
2121
byteorder = "1.5.0"
2222
p256 = { version = "0.13.2" }
2323
elliptic-curve = { version = "0.13.8", features = ["ecdh"] }

httpsig-wire-proto/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ pub const HTTPSIG_PROTO_VERSION_PK: u16 = 0x0020;
2323
/// Key types used for httpsig verification
2424
/// - Asymmetric key for public-key-based signature like ed25519, ecdsa-p256-sha256 (es256).
2525
/// - Asymmetric key to perform Diffie-Hellman key exchange for hmac-sha256 (hs256) signature.
26-
/// These are automatically generated and exposed at `/.well-known/httpsigconfigs` endpoint.
27-
/// default = ["hs256-x25519-hkdf-sha256"],
28-
/// supported = "hs256-p256-hkdf-sha256" (hmac-sha256 with hkdf via ecdh), "hs256-x25519-hkdf-sha256" (hmac-sha256 with hkdf via ecdh), "ed25519", and "es256"
26+
/// These are automatically generated and exposed at `/.well-known/httpsigconfigs` endpoint.
27+
/// default: ["hs256-x25519-hkdf-sha256"],
28+
/// supported: "hs256-p256-hkdf-sha256" (hmac-sha256 with hkdf via ecdh), "hs256-x25519-hkdf-sha256" (hmac-sha256 with hkdf via ecdh), "ed25519", and "es256"
2929
pub enum HttpSigKeyTypes {
3030
#[default]
3131
/// hs256-x25519-hkdf-sha256

modoh-bin/Cargo.toml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ publish.workspace = true
1515
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1616

1717
[features]
18-
default = ["otel-full", "otel-evil-trace"]
18+
default = ["otel-full", "otel-evil-trace", "qrlog"]
1919
otel-full = ["otel-trace", "otel-metrics", "otel-instance-id"]
2020
otel-trace = [
2121
"opentelemetry/trace",
@@ -38,6 +38,11 @@ otel-base = [
3838
"dep:opentelemetry-semantic-conventions",
3939
]
4040
otel-instance-id = ["dep:uuid"]
41+
qrlog = [
42+
"modoh-server-lib/qrlog",
43+
"tracing-subscriber/json",
44+
"tracing-subscriber/chrono",
45+
]
4146

4247
# DO NOT USE THIS IN PRODUCTION
4348
otel-evil-trace = ["modoh-server-lib/evil-trace", "otel-trace"]
@@ -47,39 +52,39 @@ modoh-server-lib = { path = "../modoh-lib", default-features = false, features =
4752
"rustls",
4853
] }
4954

50-
anyhow = "1.0.83"
55+
anyhow = "1.0.86"
5156
mimalloc = { version = "*", default-features = false }
52-
serde = { version = "1.0.202", default-features = false, features = ["derive"] }
57+
serde = { version = "1.0.208", default-features = false, features = ["derive"] }
5358
derive_builder = "0.20.0"
54-
tokio = { version = "1.37.0", default-features = false, features = [
59+
tokio = { version = "1.39.3", default-features = false, features = [
5560
"net",
5661
"rt-multi-thread",
5762
"time",
5863
"sync",
5964
"macros",
6065
] }
61-
async-trait = "0.1.80"
62-
url = "2.5.0"
66+
async-trait = "0.1.81"
67+
url = "2.5.2"
6368

6469
# config
65-
clap = { version = "4.5.4", features = ["std", "cargo", "wrap_help"] }
66-
toml = { version = "0.8.13", default-features = false, features = ["parse"] }
67-
hot_reload = "0.1.5"
70+
clap = { version = "4.5.16", features = ["std", "cargo", "wrap_help"] }
71+
toml = { version = "0.8.19", default-features = false, features = ["parse"] }
72+
hot_reload = "0.1.6"
6873

6974
# tracing and metrics
7075
tracing = { version = "0.1.40" }
71-
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] }
72-
tracing-opentelemetry = { version = "0.23.0", optional = true }
73-
opentelemetry = { version = "0.22.0", optional = true }
74-
opentelemetry_sdk = { version = "0.22.1", features = [
76+
tracing-subscriber = { version = "0.3.18", features = ["fmt"] }
77+
tracing-opentelemetry = { version = "0.25.0", optional = true }
78+
opentelemetry = { version = "0.24.0", optional = true }
79+
opentelemetry_sdk = { version = "0.24.1", features = [
7580
"rt-tokio",
7681
], optional = true }
77-
opentelemetry-stdout = { version = "0.3.0", optional = true }
78-
opentelemetry-otlp = { version = "0.15.0", optional = true }
79-
opentelemetry-semantic-conventions = { version = "0.14.0", optional = true }
82+
opentelemetry-stdout = { version = "0.5.0", optional = true }
83+
opentelemetry-otlp = { version = "0.17.0", optional = true }
84+
opentelemetry-semantic-conventions = { version = "0.16.0", optional = true }
8085

8186
# add random otel service id whenever restarting
82-
uuid = { version = "1.8.0", default-features = false, features = [
87+
uuid = { version = "1.10.0", default-features = false, features = [
8388
"v4",
8489
"fast-rng",
8590
], optional = true }

modoh-bin/src/config/parse.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::trace::TraceConfig;
2+
use crate::QrlogConfig;
23
use clap::{Arg, ArgAction};
34

45
#[cfg(any(feature = "otel-trace", feature = "otel-metrics"))]
@@ -13,6 +14,7 @@ pub struct Opts {
1314
pub config_file_path: String,
1415
pub watch: bool,
1516
pub trace_config: TraceConfig<String>,
17+
pub qrlog_config: QrlogConfig,
1618
}
1719

1820
/// Parse arg values passed from cli
@@ -40,15 +42,19 @@ pub fn parse_opts() -> Result<Opts, anyhow::Error> {
4042
.long("otel-trace")
4143
.short('t')
4244
.action(ArgAction::SetTrue)
43-
.help("Enable opentelemetry for trace. Unless explicitly specified with '-e', collector endpoint is 'http://localhost:4317'."),
45+
.help(
46+
"Enable opentelemetry for trace. Unless explicitly specified with '-e', collector endpoint is 'http://localhost:4317'.",
47+
),
4448
);
4549
#[cfg(feature = "otel-metrics")]
4650
let options = options.arg(
4751
Arg::new("otel_metrics")
4852
.long("otel-metrics")
4953
.short('m')
5054
.action(ArgAction::SetTrue)
51-
.help("Enable opentelemetry for metrics. Unless explicitly specified with '-e', collector endpoint is 'http://localhost:4317'."),
55+
.help(
56+
"Enable opentelemetry for metrics. Unless explicitly specified with '-e', collector endpoint is 'http://localhost:4317'.",
57+
),
5258
);
5359
#[cfg(any(feature = "otel-trace", feature = "otel-metrics"))]
5460
let options = options.arg(
@@ -62,6 +68,14 @@ pub fn parse_opts() -> Result<Opts, anyhow::Error> {
6268
])
6369
.help("Opentelemetry collector endpoint url connected via gRPC"),
6470
);
71+
#[cfg(feature = "qrlog")]
72+
let options = options.arg(
73+
Arg::new("qrlog")
74+
.long("qrlog")
75+
.short('q')
76+
.value_name("PATH")
77+
.help("Enable query-response logging. Unless specified, it is disabled."),
78+
);
6579

6680
let matches = options.get_matches();
6781

@@ -86,9 +100,17 @@ pub fn parse_opts() -> Result<Opts, anyhow::Error> {
86100
_marker: std::marker::PhantomData,
87101
};
88102

103+
///////////////////////////////////
104+
let qrlog_config = QrlogConfig {
105+
#[cfg(feature = "qrlog")]
106+
qrlog_path: { matches.get_one::<String>("qrlog").map(|s| s.to_owned()) },
107+
_marker: std::marker::PhantomData,
108+
};
109+
89110
Ok(Opts {
90111
config_file_path,
91112
watch,
92113
trace_config,
114+
qrlog_config,
93115
})
94116
}

modoh-bin/src/config/target_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl TryInto<ServiceConfig> for &TargetConfig {
6565
info!("Listening on {}", service_conf.listener_socket);
6666

6767
if let Some(hostname) = &self.config_toml.hostname {
68-
service_conf.hostname.clone_from(hostname);
68+
service_conf.hostname.clone_from(&hostname.to_ascii_lowercase());
6969
}
7070
info!("Hostname: {}", service_conf.hostname);
7171

modoh-bin/src/constants.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ pub const CONFIG_WATCH_DELAY_SECS: u32 = 30;
33
pub const DEFAULT_OTLP_ENDPOINT: &str = "http://localhost:4317";
44
#[cfg(any(feature = "otel-trace", feature = "otel-metrics"))]
55
pub const OTEL_SERVICE_NAMESPACE: &str = "modoh";
6+
#[cfg(feature = "otel-trace")]
7+
pub const OTEL_TRACE_BATCH_QUEUE_SIZE: usize = 8192;
8+
9+
#[cfg(feature = "qrlog")]
10+
pub const QRLOG_EVENT_NAME: &str = "qrlog";

0 commit comments

Comments
 (0)