Swiftfin icon indicating copy to clipboard operation
Swiftfin copied to clipboard

Support for custom headers?

Open sample-usr opened this issue 2 years ago • 3 comments

Describe the feature you'd like Hi, Would it be possible to include the ability to add custom headers. Something like x-api-key etc, so Jellyfin instances which are behind reverse proxies and auths like authelia for example, can use those headers to bypass those mechanisms for the mobile app. This way the mobile app would be able to communicate with the Jellyfin server, while it being still secured.

sample-usr avatar Aug 04 '23 16:08 sample-usr

I tried to implement this, but Swiftfin uses [ABJC/JellyfinAPI](https://github.com/ABJC/JellyfinAPI/tree/main?tab=readme-ov-file), a project automatically generated by [OpenAPI-Generator](https://openapi-generator.tech/docs/generators/swift5). As far as I can tell, there is no way to pass headers that are not part of the OpenAPI-Spec to the generated code without modifying it.

Apple also released their own OpenAPI-Generator, which accepts an URL-Session parameter, which can be used to add custom headers. But the last time I tried the Jellyfin-API-spec could not be parsed by Apple's implementation because it has cyclic dependencies, and replacing the entire API backend seems like a big feat.

I will leave this here for anyone else willing to try this it's not as easy as you may think, and it's certainly more work than I am currently able to put into this.

rasmuslos avatar Sep 09 '24 06:09 rasmuslos

We do not use that project, we use https://github.com/jellyfin/jellyfin-sdk-swift. The main issue with custom headers isn't our SDK but passing those along to VLCKit which doesn't support custom headers.

This should be easy for implementation within our SDK and passing along to AVPlayer, but I'm not convinced to have this implementation until our "main" player supports it, which the transition to mpv will help with (since it can do custom headers).

  • https://github.com/jellyfin/jellyfin-sdk-swift/blob/main/Sources/JellyfinClient.swift#L29C31-L29C54
  • https://developer.apple.com/documentation/foundation/urlsessionconfiguration/1411532-httpadditionalheaders
  • https://stackoverflow.com/questions/15456130/add-custom-header-field-in-request-of-avplayer

LePips avatar Sep 09 '24 07:09 LePips

Than I apologize, I didn't look properly for the SDK, sorry 😅

rasmuslos avatar Sep 09 '24 07:09 rasmuslos