🐛 Bug FIX: OpenID first login is not working properly when using config.json or ENV VARS (#4902)

* First login was not working properly

* md
This commit is contained in:
lelemm
2025-05-01 10:26:03 -03:00
committed by GitHub
parent 916a27a89a
commit 8da1c59362
4 changed files with 64 additions and 31 deletions

View File

@@ -1,7 +1,11 @@
import { generators, Issuer } from 'openid-client';
import { v4 as uuidv4 } from 'uuid';
import { clearExpiredSessions, getAccountDb } from '../account-db.js';
import {
clearExpiredSessions,
getAccountDb,
listLoginMethods,
} from '../account-db.js';
import { config } from '../load-config.js';
import {
getUserByUsername,
@@ -99,10 +103,13 @@ export async function loginWithOpenIdSetup(
[''],
);
if (countUsersWithUserName === 0) {
const valid = checkPassword(firstTimeLoginPassword);
const methods = listLoginMethods();
if (methods.some(authMethod => authMethod.method === 'password')) {
const valid = checkPassword(firstTimeLoginPassword);
if (!valid) {
return { error: 'invalid-password' };
if (!valid) {
return { error: 'invalid-password' };
}
}
}

View File

@@ -108,10 +108,14 @@ function parseHTTPSConfig(value) {
}
export async function run() {
if (config.openId) {
const openIdConfig = config?.getProperties()?.openId;
if (
openIdConfig?.discoveryURL ||
openIdConfig?.issuer?.authorization_endpoint
) {
console.log('OpenID configuration found. Preparing server to use it');
try {
const { error } = await bootstrap({ openId: config.openId }, true);
const { error } = await bootstrap({ openId: openIdConfig }, true);
if (error) {
console.log(error);
} else {