fix(secu): don't store komga pwd but authstring
This commit is contained in:
@@ -21,10 +21,7 @@ export abstract class BaseApiService {
|
||||
const config = await ConfigDBService.getConfig();
|
||||
return {
|
||||
serverUrl: config.url,
|
||||
credentials: {
|
||||
username: config.username,
|
||||
password: config.password,
|
||||
},
|
||||
authHeader: config.authHeader,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la récupération de la configuration:", error);
|
||||
@@ -33,16 +30,12 @@ export abstract class BaseApiService {
|
||||
}
|
||||
|
||||
protected static getAuthHeaders(config: AuthConfig): Headers {
|
||||
if (!config.credentials?.username || !config.credentials?.password) {
|
||||
if (!config.authHeader) {
|
||||
throw new Error("Credentials Komga manquants");
|
||||
}
|
||||
|
||||
const auth = Buffer.from(
|
||||
`${config.credentials.username}:${config.credentials.password}`
|
||||
).toString("base64");
|
||||
|
||||
return new Headers({
|
||||
Authorization: `Basic ${auth}`,
|
||||
Authorization: `Basic ${config.authHeader}`,
|
||||
Accept: "application/json",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ interface KomgaConfigData {
|
||||
url: string;
|
||||
username: string;
|
||||
password: string;
|
||||
authHeader: string;
|
||||
}
|
||||
|
||||
interface TTLConfigData {
|
||||
@@ -37,13 +38,16 @@ export class ConfigDBService {
|
||||
const user = this.getCurrentUser();
|
||||
await connectDB();
|
||||
|
||||
const authHeader = Buffer.from(`${data.username}:${data.password}`).toString("base64");
|
||||
|
||||
const config = await KomgaConfig.findOneAndUpdate(
|
||||
{ userId: user.id },
|
||||
{
|
||||
userId: user.id,
|
||||
url: data.url,
|
||||
username: data.username,
|
||||
password: data.password,
|
||||
// password: data.password,
|
||||
authHeader,
|
||||
},
|
||||
{ upsert: true, new: true }
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user