Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add environment variable for API key #831

Merged
merged 16 commits into from
Sep 16, 2024

Conversation

AidanHilt
Copy link
Contributor

@AidanHilt AidanHilt commented Jun 23, 2024

Description

Adds an environment variable, API_KEY, that can be used to set the API key. If the environment variable is not set, the previous method is used.

Screenshot (if UI-related)

To-Dos

  • Successful build yarn build
  • Translation keys yarn i18n:extract
  • Database migration (if required)

Issues Fixed or Closed

This doesn't fix any filed issues, the need for this came up from my own projects.

@AidanHilt AidanHilt requested a review from fallenbagel as a code owner June 23, 2024 04:14
@gauthier-th
Copy link
Collaborator

For what use cases do you need this?

@AidanHilt
Copy link
Contributor Author

The main advantage of this setup is for people who use tools like: https://github.com/buildarr/buildarr-jellyseerr. Buildarr is a configuration management tool for the Jellyseerr and the -arr stack, and it can completely initialize Jellyseerr automatically, if provided with the API key. This makes it possible to generate that key externally, and then provide it to both Jellyseerr and a configuration management tool like Buildarr.

@gauthier-th gauthier-th changed the title Add environment variable for API key feat: add environment variable for API key Jul 9, 2024
Copy link
Collaborator

@gauthier-th gauthier-th left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please rebase your PR on develop and add information about this setting in the documentation?

src/i18n/locale/en.json Outdated Show resolved Hide resolved
@AidanHilt
Copy link
Contributor Author

AidanHilt commented Aug 3, 2024

I removed the change to the translation, pulled the latest changes from develop, and added documentation about the API key

Copy link
Collaborator

@gauthier-th gauthier-th left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you've done won't work if the API_KEY environment variable is changed after the 1st restart of Jellyseerr, unless you click on "regenerate" after setting it.

It seems odd to have to regenerate a key you've just defined manually, so you should add a check each time you start Jellyseerr to check whether there's an API_KEY environment variable, and if so change the main settings with this key.

@AidanHilt
Copy link
Contributor Author

Alright, I went ahead and added a check when the settings load, if the environment variable is set it will read that and use that at startup. I made sure to pull in the latest changes on develop. Documentation is still updated as well. Anything else I should adjust or any changes to be made?

Copy link
Collaborator

@gauthier-th gauthier-th left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gauthier-th gauthier-th merged commit 45ef150 into fallenbagel:develop Sep 16, 2024
8 checks passed
@fallenbagel
Copy link
Owner

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

bonswouar pushed a commit to bonswouar/jellyseerr that referenced this pull request Nov 10, 2024
* 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
thibodelanghe pushed a commit to thibodelanghe/jellyseerr that referenced this pull request Dec 18, 2024
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants