fix: Redis のユーザー指定に対応 (issue #20)#21
Merged
Merged
Conversation
Redis 6+ ACL のユーザー名を指定可能にする。 空文字の場合は default ユーザーとして接続する。 設定ファイル・wiki・ConfigTest も更新。
Lettuce で RedisURI/RedisClient を構築し、RedisConfig.user を ACL ユーザー名にマップ。接続失敗時は DB 同様にプラグイン起動を継続 (Redis 依存機能を無効化)。DI と onEnable/onDisable ライフサイクルに 統合。実接続しない buildUri の単体テストを追加。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
issue #20「Redisのユーザー指定がない」を解決しました。
Redis 6+ の ACL では
default以外のユーザーを使う環境があり、RedisConfigにuserフィールドが欠けていたため認証できず困る状態でした。DatabaseConfigと同様にuserフィールドを追加し、あわせて実際にuserを使う Redis 接続層(RedisManager)を実装しました。変更内容
1.
RedisConfigにuserフィールドを追加 (feat)src/main/kotlin/.../data/Config.kt:RedisConfigにuser: String = ""を追加(空文字=defaultユーザー)config.ymlおよび integrationTest の各 config)、wiki/CONFIGURATION.md、既存ConfigTestを更新2. Redis 接続管理 (RedisManager) を追加 (feat)
src/main/kotlin/.../database/RedisManager.kt(新規): Lettuce でRedisURI/RedisClientを構築RedisConfig.user→RedisURI.username(ACL ユーザー名)、password→withPassword()にマップconnect()でPINGを実行し設定ミスを即時検出disconnect()で確実に shutdownsyncCommands()/asyncCommands()でコマンド API を取得(未接続時はnull)ConfigModuleにprovideRedisConfig()、SimpleQuestComponentにredisManager()を追加SimpleQuestのonEnableで接続・成否ログ、onDisableで切断RedisManagerTest.kt(新規):buildUri()の host/port/user/password マッピングを実接続なしで検証補足
RedisURI.BuilderにはwithUsernameがなく、usernameは構築後のRedisURIにしかセットできないためそのように実装RedisURI.getUsername()は未設定時にnullを返す(空文字ではない)点に合わせてテストを記述確認
./gradlew test: BUILD SUCCESSFUL./gradlew build: BUILD SUCCESSFULactions-upによる GitHub Actions の SHA pin 更新を実施ghasec --onlineによる静的解析: エラーなしCloses #20