mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-03-01 05:29:41 +00:00
Require email_verified to be explicitly true when enforcement is enabled
Previously the check only rejected email_verified === false, allowing logins when the claim was missing entirely. Since the admin opted in, the IdP is expected to provide the claim.
This commit is contained in:
parent
b3d63f4158
commit
49aeb2da19
2 changed files with 9 additions and 7 deletions
|
|
@ -168,7 +168,7 @@ class OidcAuthStrategy {
|
|||
}
|
||||
|
||||
// Enforce email_verified check on every login if configured
|
||||
if (global.ServerSettings.authOpenIDRequireVerifiedEmail && userinfo.email_verified === false) {
|
||||
if (global.ServerSettings.authOpenIDRequireVerifiedEmail && userinfo.email_verified !== true) {
|
||||
throw new AuthError('Email is not verified', 401)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -481,14 +481,16 @@ describe('OidcAuthStrategy', function () {
|
|||
expect(result).to.equal(user)
|
||||
})
|
||||
|
||||
it('should allow login when email_verified is missing and enforcement is on', async function () {
|
||||
// Only reject when explicitly false, not when absent
|
||||
it('should reject login when email_verified is missing and enforcement is on', async function () {
|
||||
global.ServerSettings.authOpenIDRequireVerifiedEmail = true
|
||||
const user = makeUser()
|
||||
DatabaseStub.userModel.findUserFromOpenIdUserInfo.resolves(user)
|
||||
|
||||
const result = await strategy.verifyUser({ id_token: 'tok' }, { sub: 'sub-1', email: 'a@b.com' })
|
||||
expect(result).to.equal(user)
|
||||
try {
|
||||
await strategy.verifyUser({ id_token: 'tok' }, { sub: 'sub-1', email: 'a@b.com' })
|
||||
expect.fail('should have thrown')
|
||||
} catch (err) {
|
||||
expect(err.message).to.equal('Email is not verified')
|
||||
expect(err.statusCode).to.equal(401)
|
||||
}
|
||||
})
|
||||
|
||||
it('should auto-register new user when enabled', async function () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue