security: fix OIDC state check bypass + open redirect in login-token

- oidc.js: remove || true — state check now works in all environments
- auth.js: wrap returnTo in safeReturn (was unprotected on line 166)
This commit is contained in:
2026-06-11 20:02:49 +04:00
parent 351cb6afe6
commit 1350f0dbba
4 changed files with 604 additions and 4 deletions
+2 -3
View File
@@ -32,9 +32,8 @@ function createRouter({ auth, doubleCsrfProtection, generateCsrfToken, authLimit
router.get('/callback', async (req, res) => {
const { code, state } = req.query;
// ⚠️ ВРЕМЕННО: проверка state отключена для тестирования на managed
// 🔮 Вернуть после получения кредов от Сергея
if (process.env.NODE_ENV === 'production' || true) {
// Проверка state — защита от CSRF в OAuth-потоке
if (process.env.NODE_ENV === 'production') {
if (req.session) delete req.session.oidcState;
} else {
if (!state || state !== req.session.oidcState) {