somratpro commited on
Commit
fdf0380
·
1 Parent(s): ad703e3

debug: also inspect external:* keys in Redis check

Browse files
Files changed (1) hide show
  1. health-server.js +22 -15
health-server.js CHANGED
@@ -1949,25 +1949,32 @@ const server = http.createServer((req, res) => {
1949
  redisSection += `Redis keyspace:\n${keyspace || "(empty)"}\n\n`;
1950
 
1951
  // Check DB 0 (default) and DB 1 for all keys
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1952
  for (const db of [0, 1, 2]) {
1953
  const dbFlag = db === 0 ? "" : `-n ${db}`;
1954
  const allKeys = rc(`redis-cli -h 127.0.0.1 -p 6379 ${dbFlag} keys "*" 2>/dev/null`);
1955
- const loginKeys = rc(`redis-cli -h 127.0.0.1 -p 6379 ${dbFlag} keys "login:*" 2>/dev/null`);
1956
  redisSection += `DB ${db}: total keys preview: ${allKeys ? allKeys.split("\n").slice(0,8).join(", ") : "(none)"}\n`;
1957
- redisSection += `DB ${db}: login:* keys: ${loginKeys || "(none)"}\n`;
1958
- if (loginKeys && !loginKeys.startsWith("(")) {
1959
- for (const key of loginKeys.split("\n").filter(Boolean).slice(0, 3)) {
1960
- const val = rc(`redis-cli -h 127.0.0.1 -p 6379 ${dbFlag} get "${key}" 2>/dev/null`);
1961
- const ttl = rc(`redis-cli -h 127.0.0.1 -p 6379 ${dbFlag} ttl "${key}" 2>/dev/null`);
1962
- if (!val) { redisSection += ` ${key}: EMPTY!\n`; continue; }
1963
- const colonIdx = val.indexOf(":");
1964
- const token = colonIdx > 0 ? val.slice(0, colonIdx) : "";
1965
- const secret = colonIdx > 0 ? val.slice(colonIdx + 1) : "";
1966
- const extraColons = (val.match(/:/g) || []).length - 1;
1967
- const note = colonIdx < 0 ? "⚠ NO COLON!" : extraColons > 0 ? `⚠ ${extraColons} extra colon(s)` : secret.length < 30 ? "⚠ secret short" : "✓ ok";
1968
- redisSection += ` ${key} [TTL=${ttl}s]\n token: ${token.slice(0,12)}... (len=${token.length})\n secret: ${secret.slice(0,12)}... (len=${secret.length})\n note: ${note}\n`;
1969
- }
1970
- }
1971
  redisSection += "\n";
1972
  }
1973
  } catch (e) {
 
1949
  redisSection += `Redis keyspace:\n${keyspace || "(empty)"}\n\n`;
1950
 
1951
  // Check DB 0 (default) and DB 1 for all keys
1952
+ // Also inspect external:* keys — Postiz stores codeVerifier under external:{oauth_token}
1953
+ const inspectKeys = (db, pattern) => {
1954
+ const dbFlag = db === 0 ? "" : `-n ${db}`;
1955
+ const keys = rc(`redis-cli -h 127.0.0.1 -p 6379 ${dbFlag} keys "${pattern}" 2>/dev/null`);
1956
+ if (!keys || keys.startsWith("(")) return ` ${pattern}: (none)\n`;
1957
+ let out = ` ${pattern} keys found:\n`;
1958
+ for (const key of keys.split("\n").filter(Boolean).slice(0, 5)) {
1959
+ const val = rc(`redis-cli -h 127.0.0.1 -p 6379 ${dbFlag} get "${key}" 2>/dev/null`);
1960
+ const ttl = rc(`redis-cli -h 127.0.0.1 -p 6379 ${dbFlag} ttl "${key}" 2>/dev/null`);
1961
+ if (!val) { out += ` ${key}: EMPTY! [TTL=${ttl}]\n`; continue; }
1962
+ const colonIdx = val.indexOf(":");
1963
+ const token = colonIdx > 0 ? val.slice(0, colonIdx) : "";
1964
+ const secret = colonIdx > 0 ? val.slice(colonIdx + 1) : "";
1965
+ const extraColons = (val.match(/:/g) || []).length - 1;
1966
+ const note = colonIdx < 0 ? "⚠ NO COLON" : extraColons > 0 ? `⚠ ${extraColons} extra colon(s)` : secret.length < 30 ? "⚠ secret short" : "✓ ok";
1967
+ out += ` ${key} [TTL=${ttl}s]\n token: ${token.slice(0,12)}... (len=${token.length})\n secret: ${secret.slice(0,12)}... (len=${secret.length})\n note: ${note}\n`;
1968
+ }
1969
+ return out;
1970
+ };
1971
+
1972
  for (const db of [0, 1, 2]) {
1973
  const dbFlag = db === 0 ? "" : `-n ${db}`;
1974
  const allKeys = rc(`redis-cli -h 127.0.0.1 -p 6379 ${dbFlag} keys "*" 2>/dev/null`);
 
1975
  redisSection += `DB ${db}: total keys preview: ${allKeys ? allKeys.split("\n").slice(0,8).join(", ") : "(none)"}\n`;
1976
+ redisSection += inspectKeys(db, "login:*");
1977
+ redisSection += inspectKeys(db, "external:*");
 
 
 
 
 
 
 
 
 
 
 
 
1978
  redisSection += "\n";
1979
  }
1980
  } catch (e) {