You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Set session cookie for UI requests with Bearer Authorization #9170
enhancementNew features or improvements of some kind, as opposed to a problem (bug)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussionneeds-triageNew issues needed to be validated
Currently, the app uses a rather ugly hack to open the web UI without prompting for credentials. During startup the username and password is always reset, which tends to confuse users as in syncthing/syncthing-android#1710
This is only necessary because the WebView previously relied only on intercepting the HTTP basic auth prompt. With the changes in syncthing/syncthing-android#1982 we can send any HTTP header in the initial request.
I see no real use case for this; adding further layers of ugly hacks to support weirdness in the Android wrapper is not appealing. Why doesn't the app just make a login request, get a cookie like the UI does, and set that cookie in the header?
Why doesn't the app just make a login request, get a cookie like the UI does, and set that cookie in the header?
That's roughly the gist of syncthing/syncthing-android#1982. We send basic auth credentials in the initial request and rely on the session cookie afterwards.
I see no real use case for this; adding further layers of ugly hacks to support weirdness in the Android wrapper is not appealing.
IMHO, it's odd that the app or any other wrapper has to either keep authentication disabled or (ab)use credentials intended for an interactive user login.
Using the API key is dead simple as it only requires read access to the configuration to retrieve the current value. The user is free to alter his credentials and also the key itself.
This obviously doesn't work with credentials as the password is hashed and needs to be reset by the wrapper if changed.
The web UI is interactive usage. The API key is for API usage. I don't think mixing the two is particularly great. I don't know why the Android app does what it does and has the problems it has, as opposed to other integrations on other platforms.
I think that most use of the Android app if unaffected by the web API changes, but the app also includes the option to launch the upstream Syncthing web UI in a WebView (to access features that are available in the upstream UI but not in the Android app UI), which is partially siloed off from the rest of the app as I understand it. So while the app can use the API key for most things, the WebView is a bit different.
But I think that once we get #8417 revived and merged, there could be a somewhat okay solution that needs no further changes in upstream Syncthing. With Webauthn support, the Android app could implement a software authenticator and exercise the API to pre-authenticate and retrieve a session cookie. Assuming that session cookie can then be injected into the WebView, the password/API key hack should then no longer be necessary.
(Automatic) authentication with password (HTML form or Authorization: Basic header) is "not possible" because the password is not stored in cleartext.
Which is why the app abuses the password by resetting it to equal the API key, so the API key can be used "as a password" to exchange for a session cookie.
But as noted, #8417 would add a third option which could be performed automatically and still receive a session cookie.
enhancementNew features or improvements of some kind, as opposed to a problem (bug)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussionneeds-triageNew issues needed to be validated
Activity
calmh commentedon Oct 12, 2023
I see no real use case for this; adding further layers of ugly hacks to support weirdness in the Android wrapper is not appealing. Why doesn't the app just make a login request, get a cookie like the UI does, and set that cookie in the header?
bt90 commentedon Oct 12, 2023
That's roughly the gist of syncthing/syncthing-android#1982. We send basic auth credentials in the initial request and rely on the session cookie afterwards.
IMHO, it's odd that the app or any other wrapper has to either keep authentication disabled or (ab)use credentials intended for an interactive user login.
Using the API key is dead simple as it only requires read access to the configuration to retrieve the current value. The user is free to alter his credentials and also the key itself.
This obviously doesn't work with credentials as the password is hashed and needs to be reset by the wrapper if changed.
calmh commentedon Oct 12, 2023
The web UI is interactive usage. The API key is for API usage. I don't think mixing the two is particularly great. I don't know why the Android app does what it does and has the problems it has, as opposed to other integrations on other platforms.
emlun commentedon Oct 13, 2023
I think that most use of the Android app if unaffected by the web API changes, but the app also includes the option to launch the upstream Syncthing web UI in a WebView (to access features that are available in the upstream UI but not in the Android app UI), which is partially siloed off from the rest of the app as I understand it. So while the app can use the API key for most things, the WebView is a bit different.
But I think that once we get #8417 revived and merged, there could be a somewhat okay solution that needs no further changes in upstream Syncthing. With Webauthn support, the Android app could implement a software authenticator and exercise the API to pre-authenticate and retrieve a session cookie. Assuming that session cookie can then be injected into the WebView, the password/API key hack should then no longer be necessary.
emlun commentedon Oct 13, 2023
And to perhaps answer this question a little more thoroughly:
Because
X-Api-KeyorAuthorization: Bearerheader) does not return a session cookie.Authorization: Basicheader) is "not possible" because the password is not stored in cleartext.But as noted, #8417 would add a third option which could be performed automatically and still receive a session cookie.