From 4c9356a14903ca208a712ab07e5b6fec94cfe2b5 Mon Sep 17 00:00:00 2001 From: malken21 <77374813+malken21@users.noreply.github.com> Date: Tue, 17 Nov 2026 19:26:08 +0900 Subject: [PATCH] chore: remove internal host names from scripts and comments - scripts/set-env.sh and scripts/set-bot-token.sh take the env file path from TORO_AUTH_ENV and the compose service name from AUTH_SERVICE. Both are required and the scripts fail with a message when unset. - Comments, the README title, test temp directory names and the docker build example no longer use the internal name. - Crate name, binary name and Dockerfile artifact paths are unchanged. --- Dockerfile | 4 ++-- README.md | 2 +- scripts/set-bot-token.sh | 8 +++++--- scripts/set-env.sh | 5 +++-- src/auth/tokens.rs | 2 +- src/main.rs | 3 ++- src/oauth/grants.rs | 2 +- tests/auth.rs | 2 +- tests/common/mod.rs | 2 +- 9 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index fb7c791..36a3255 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -# toro-auth: auth.torosaba.net (共通認証) +# auth.torosaba.net (共通認証) # -# docker build -t toro-auth . +# docker build -t auth . # # musl で静的にリンクして scratch に載せる。CA 証明書はバイナリに埋め込んである (webpki-roots) diff --git a/README.md b/README.md index 8c11a8b..33df44d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# toro-auth +# TORO-Auth TORO Server の共通認証サービスです。Rust で書かれています。 diff --git a/scripts/set-bot-token.sh b/scripts/set-bot-token.sh index 68b7106..05de49d 100644 --- a/scripts/set-bot-token.sh +++ b/scripts/set-bot-token.sh @@ -1,9 +1,11 @@ #!/bin/bash -# Discord の Bot トークンを toro-auth.env に入れて、toro-auth を入れ直す (サーバーの上で動かす)。 +# Discord の Bot トークンを認証サービスの env ファイルに入れて、認証サービスを入れ直す (サーバーの上で動かす)。 +# 必須の環境変数: TORO_AUTH_ENV (env ファイルのパス)、AUTH_SERVICE (compose のサービス名) # 入力は画面に出ない。ギルドのロールを読めるトークンだけを保存する。 set -euo pipefail -ENV_FILE="${TORO_AUTH_ENV:-/home/toroserver/toro-auth.env}" +ENV_FILE="${TORO_AUTH_ENV:?TORO_AUTH_ENV に env ファイルのパスを指定してください}" +AUTH_SERVICE="${AUTH_SERVICE:?AUTH_SERVICE に compose の認証サービス名を指定してください}" COMPOSE_DIR="${TORO_COMPOSE_DIR:-/home/toroserver}" [ -f "$ENV_FILE" ] || { echo "$ENV_FILE がありません" >&2; exit 1; } @@ -33,5 +35,5 @@ chgrp --reference="$ENV_FILE" "$tmp" mv "$tmp" "$ENV_FILE" cd "$COMPOSE_DIR" -docker compose up -d --no-deps --force-recreate toro-auth +docker compose up -d --no-deps --force-recreate "$AUTH_SERVICE" echo "完了。auth.torosaba.net を開き直すと、ロールの名前が出ます" diff --git a/scripts/set-env.sh b/scripts/set-env.sh index eb02f40..0a86d21 100644 --- a/scripts/set-env.sh +++ b/scripts/set-env.sh @@ -1,10 +1,11 @@ #!/bin/bash -# toro-auth.env の秘密を入力する (サーバーの上で動かす)。 +# 認証サービスの env ファイルの秘密を入力する (サーバーの上で動かす)。 +# 必須の環境変数: TORO_AUTH_ENV (env ファイルのパス) # 入力は画面に出ない。空のまま Enter を押すと、今の値を残す。 # JWT_SECRET は変えない (変えると全員がログアウトされる)。 set -euo pipefail -ENV_FILE="${TORO_AUTH_ENV:-/home/toroserver/toro-auth.env}" +ENV_FILE="${TORO_AUTH_ENV:?TORO_AUTH_ENV に env ファイルのパスを指定してください}" [ -f "$ENV_FILE" ] || { echo "$ENV_FILE がありません" >&2; exit 1; } diff --git a/src/auth/tokens.rs b/src/auth/tokens.rs index ea59d86..69c662f 100644 --- a/src/auth/tokens.rs +++ b/src/auth/tokens.rs @@ -89,7 +89,7 @@ mod tests { use super::*; fn temp_dir(name: &str) -> PathBuf { - let dir = std::env::temp_dir().join(format!("toro-auth-{name}-{}", random_hex(6))); + let dir = std::env::temp_dir().join(format!("auth-{name}-{}", random_hex(6))); std::fs::create_dir_all(&dir).unwrap(); dir } diff --git a/src/main.rs b/src/main.rs index 779b05d..fabc645 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,7 +29,8 @@ async fn main() { .await .expect("bind internal"); eprintln!( - "toro-auth {} listening on :{port} (internal :{internal_port})", + "{} {} listening on :{port} (internal :{internal_port})", + env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION") ); diff --git a/src/oauth/grants.rs b/src/oauth/grants.rs index 6dfcfc8..84e7f28 100644 --- a/src/oauth/grants.rs +++ b/src/oauth/grants.rs @@ -243,7 +243,7 @@ mod tests { const IDLE: i64 = 1000; fn temp_dir(name: &str) -> PathBuf { - let dir = std::env::temp_dir().join(format!("toro-auth-{name}-{}", random_hex(6))); + let dir = std::env::temp_dir().join(format!("auth-{name}-{}", random_hex(6))); std::fs::create_dir_all(&dir).unwrap(); dir } diff --git a/tests/auth.rs b/tests/auth.rs index 0e0d85d..b4408ab 100644 --- a/tests/auth.rs +++ b/tests/auth.rs @@ -356,7 +356,7 @@ async fn token_is_never_shown_again_after_it_is_issued() { #[tokio::test] async fn failing_to_save_the_record_issues_no_token() { - let missing = std::env::temp_dir().join("toro-auth-test-does-not-exist"); + let missing = std::env::temp_dir().join("auth-test-does-not-exist"); let server = start_with(|cfg| cfg.state_dir = missing.to_string_lossy().into_owned()).await; let cookie = server.login("member").await; let res = server diff --git a/tests/common/mod.rs b/tests/common/mod.rs index e17006e..70fa6ad 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -132,7 +132,7 @@ pub async fn start_with(customize: impl FnOnce(&mut Config)) -> TestServer { let internal = format!("http://{}", internal_listener.local_addr().unwrap()); let state_dir = - std::env::temp_dir().join(format!("toro-auth-test-{}", toro_auth::util::random_hex(8))); + std::env::temp_dir().join(format!("auth-test-{}", toro_auth::util::random_hex(8))); std::fs::create_dir_all(&state_dir).unwrap(); let mut cfg = Config {