@ahhaohho/auth-middleware 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahhaohho/auth-middleware",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Shared authentication middleware with Passport.js for ahhaohho microservices",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -36,8 +36,16 @@ class RedisManager {
36
36
  maxRetriesPerRequest: null
37
37
  };
38
38
 
39
- // ElastiCache 사용 시 TLS 활성화
40
- if (process.env.ELASTICACHE_ENDPOINT) {
39
+ // TLS 활성화 조건:
40
+ // 1. REDIS_TLS가 명시적으로 'true'로 설정된 경우
41
+ // 2. REDIS_HOST가 설정되지 않고 ELASTICACHE_ENDPOINT를 사용하는 경우
42
+ // 3. localhost/127.0.0.1이 아닌 경우
43
+ const isLocalhost = ['localhost', '127.0.0.1'].includes(config.host);
44
+ const shouldUseTLS =
45
+ process.env.REDIS_TLS === 'true' ||
46
+ (!process.env.REDIS_HOST && process.env.ELASTICACHE_ENDPOINT);
47
+
48
+ if (shouldUseTLS && !isLocalhost) {
41
49
  config.tls = {};
42
50
  }
43
51