mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2026-02-05 18:32:53 +00:00
Fix #5274 2fa backup codes not validating properly
This commit is contained in:
@@ -198,20 +198,23 @@ const internal2fa = {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try TOTP code first
|
// Try TOTP code first, if it's 6 chars. it will throw errors if it's not 6 chars
|
||||||
const result = await verify({
|
// and the backup codes are 8 chars.
|
||||||
token,
|
if (token.length === 6) {
|
||||||
secret,
|
const result = await verify({
|
||||||
});
|
token,
|
||||||
|
secret,
|
||||||
|
});
|
||||||
|
|
||||||
if (result.valid) {
|
if (result.valid) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try backup codes
|
// Try backup codes
|
||||||
const backupCodes = auth?.meta?.backup_codes || [];
|
const backupCodes = auth?.meta?.backup_codes || [];
|
||||||
for (let i = 0; i < backupCodes.length; i++) {
|
for (let i = 0; i < backupCodes.length; i++) {
|
||||||
const match = await bcrypt.compare(code.toUpperCase(), backupCodes[i]);
|
const match = await bcrypt.compare(token.toUpperCase(), backupCodes[i]);
|
||||||
if (match) {
|
if (match) {
|
||||||
// Remove used backup code
|
// Remove used backup code
|
||||||
const updatedCodes = [...backupCodes];
|
const updatedCodes = [...backupCodes];
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
},
|
},
|
||||||
"code": {
|
"code": {
|
||||||
"minLength": 6,
|
"minLength": 6,
|
||||||
"maxLength": 6,
|
"maxLength": 8,
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "012345"
|
"example": "012345"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"description": "Verififcation Payload",
|
"description": "Verification Payload",
|
||||||
"required": true,
|
"required": true,
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"code": {
|
"code": {
|
||||||
"minLength": 6,
|
"minLength": 6,
|
||||||
"maxLength": 6,
|
"maxLength": 8,
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "123456"
|
"example": "123456"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"description": "Verififcation Payload",
|
"description": "Verification Payload",
|
||||||
"required": true,
|
"required": true,
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"code": {
|
"code": {
|
||||||
"minLength": 6,
|
"minLength": 6,
|
||||||
"maxLength": 6,
|
"maxLength": 8,
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "123456"
|
"example": "123456"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user