-
-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jellyfinapi): switch to API tokens instead of auth tokens (#868)
* feat(jellyfinapi): create Jellyfin API key from admin user * fix(jellyfinapi): add migration script for Jellyfin API key * feat(jellyfinapi): use Jellyfin API key instead of admin auth token * fix(jellyfinapi): fix api key migration * feat(jellyfinapi): add API key field to Jellyfin settings * fix: move the API key field in the Jellyfin settings
- Loading branch information
1 parent
12f908d
commit bd4da6d
Showing
13 changed files
with
308 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import JellyfinAPI from '@server/api/jellyfin'; | ||
import { MediaServerType } from '@server/constants/server'; | ||
import { getRepository } from '@server/datasource'; | ||
import { User } from '@server/entity/User'; | ||
import type { AllSettings } from '@server/lib/settings'; | ||
import { getHostname } from '@server/utils/getHostname'; | ||
|
||
const migrateApiTokens = async (settings: any): Promise<AllSettings> => { | ||
const mediaServerType = settings.main.mediaServerType; | ||
if ( | ||
!settings.jellyfin.apiKey && | ||
(mediaServerType === MediaServerType.JELLYFIN || | ||
mediaServerType === MediaServerType.EMBY) | ||
) { | ||
const userRepository = getRepository(User); | ||
const admin = await userRepository.findOne({ | ||
where: { id: 1 }, | ||
select: ['id', 'jellyfinAuthToken', 'jellyfinUserId', 'jellyfinDeviceId'], | ||
order: { id: 'ASC' }, | ||
}); | ||
if (!admin) { | ||
return settings; | ||
} | ||
const jellyfinClient = new JellyfinAPI( | ||
getHostname(settings.jellyfin), | ||
admin.jellyfinAuthToken, | ||
admin.jellyfinDeviceId | ||
); | ||
jellyfinClient.setUserId(admin.jellyfinUserId ?? ''); | ||
const apiKey = await jellyfinClient.createApiToken('Jellyseerr'); | ||
settings.jellyfin.apiKey = apiKey; | ||
} | ||
return settings; | ||
}; | ||
|
||
export default migrateApiTokens; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.