feat: add environment variable for API key (#831)
* Added the ability to set the API key with the env var API_KEY * Adding debug statements * Updating * feat: adding env var for API key * feat: update * fix(settings/index.ts): remove a print statement that logs the API key to the console * Update en.json * docs: added documentation about API_KEY environment variable * feat: add a check to ensure API key always uses env var if provided * feat: always check the API_KEY env var at startup * chore: add back the gitkeeps under ./config, accidentally deleted in prev commit * chore: revert change made to docker-compose that was accidentally committed
This commit is contained in:
@@ -12,6 +12,8 @@ This is your Jellyseerr API key, which can be used to integrate Jellyseerr with
|
|||||||
|
|
||||||
If you need to generate a new API key for any reason, simply click the button to the right of the text box.
|
If you need to generate a new API key for any reason, simply click the button to the right of the text box.
|
||||||
|
|
||||||
|
If you want to set the API key, rather than letting it be randomly generated, you can use the API_KEY environment variable. Whatever that variable is set to will be your API key.
|
||||||
|
|
||||||
## Application Title
|
## Application Title
|
||||||
|
|
||||||
If you aren't a huge fan of the name "Jellyseerr" and would like to display something different to your users, you can customize the application title!
|
If you aren't a huge fan of the name "Jellyseerr" and would like to display something different to your users, you can customize the application title!
|
||||||
|
|||||||
@@ -611,8 +611,12 @@ class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private generateApiKey(): string {
|
private generateApiKey(): string {
|
||||||
|
if (process.env.API_KEY) {
|
||||||
|
return process.env.API_KEY;
|
||||||
|
} else {
|
||||||
return Buffer.from(`${Date.now()}${randomUUID()}`).toString('base64');
|
return Buffer.from(`${Date.now()}${randomUUID()}`).toString('base64');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private generateVapidKeys(force = false): void {
|
private generateVapidKeys(force = false): void {
|
||||||
if (!this.data.vapidPublic || !this.data.vapidPrivate || force) {
|
if (!this.data.vapidPublic || !this.data.vapidPrivate || force) {
|
||||||
@@ -648,6 +652,12 @@ class Settings {
|
|||||||
|
|
||||||
this.data = merge(this.data, parsedJson);
|
this.data = merge(this.data, parsedJson);
|
||||||
|
|
||||||
|
if (process.env.API_KEY) {
|
||||||
|
if (this.main.apiKey != process.env.API_KEY) {
|
||||||
|
this.main.apiKey = process.env.API_KEY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.save();
|
this.save();
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
Reference in New Issue
Block a user