|
|
@ -187,7 +187,7 @@ export default class Noco { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await Noco._ncMeta.metaInit(); |
|
|
|
await Noco._ncMeta.metaInit(); |
|
|
|
await this.readOrGenJwtSecret(); |
|
|
|
await this.initJwt(); |
|
|
|
await initAdminFromEnv(); |
|
|
|
await initAdminFromEnv(); |
|
|
|
|
|
|
|
|
|
|
|
await NcUpgrader.upgrade({ ncMeta: Noco._ncMeta }); |
|
|
|
await NcUpgrader.upgrade({ ncMeta: Noco._ncMeta }); |
|
|
@ -489,20 +489,28 @@ export default class Noco { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async readOrGenJwtSecret(): Promise<any> { |
|
|
|
private async initJwt(): Promise<any> { |
|
|
|
if (this.config?.auth?.jwt && !this.config.auth.jwt.secret) { |
|
|
|
if (this.config?.auth?.jwt) { |
|
|
|
let secret = ( |
|
|
|
if (!this.config.auth.jwt.secret) { |
|
|
|
await Noco._ncMeta.metaGet('', '', 'nc_store', { |
|
|
|
let secret = ( |
|
|
|
key: 'nc_auth_jwt_secret' |
|
|
|
await Noco._ncMeta.metaGet('', '', 'nc_store', { |
|
|
|
}) |
|
|
|
key: 'nc_auth_jwt_secret' |
|
|
|
)?.value; |
|
|
|
}) |
|
|
|
if (!secret) { |
|
|
|
)?.value; |
|
|
|
await Noco._ncMeta.metaInsert('', '', 'nc_store', { |
|
|
|
if (!secret) { |
|
|
|
key: 'nc_auth_jwt_secret', |
|
|
|
await Noco._ncMeta.metaInsert('', '', 'nc_store', { |
|
|
|
value: secret = uuidv4() |
|
|
|
key: 'nc_auth_jwt_secret', |
|
|
|
}); |
|
|
|
value: secret = uuidv4() |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.config.auth.jwt.secret = secret; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.config.auth.jwt.options = this.config.auth.jwt.options || {}; |
|
|
|
|
|
|
|
if (!this.config.auth.jwt.options?.expiresIn) { |
|
|
|
|
|
|
|
this.config.auth.jwt.options.expiresIn = |
|
|
|
|
|
|
|
process.env.NC_JWT_EXPIRES_IN ?? '10h'; |
|
|
|
} |
|
|
|
} |
|
|
|
this.config.auth.jwt.secret = secret; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
let serverId = ( |
|
|
|
let serverId = ( |
|
|
|
await Noco._ncMeta.metaGet('', '', 'nc_store', { |
|
|
|
await Noco._ncMeta.metaGet('', '', 'nc_store', { |
|
|
|