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

[BUG] Cantook OPDS Reader issues #346

Closed
GregTroar opened this issue May 28, 2024 · 26 comments
Closed

[BUG] Cantook OPDS Reader issues #346

GregTroar opened this issue May 28, 2024 · 26 comments
Labels
bug Something isn't working

Comments

@GregTroar
Copy link

GregTroar commented May 28, 2024

Describe the bug
I have tried Monnreader+ as well as Cantook on Android and I cannot access to the OPDS feed.
On Cantook I keep getting a 401 error (unauthorized), I am using the url https://login:pass@ip:port/opds/v1.2/catalog, tried also without the login and pass in URL and also not working.

For Moonreader+ it just shows the xml file saying that it does not recognize the file so it is like this:

WhatsApp Image 2024-05-28 à 14 51 23_7fc7ec49

To Reproduce
Steps to reproduce the behavior:

  1. Go to Moonreader+
  2. Create OPDS Catalog and put your URL
  3. Click on it
  4. See error

Expected behavior
Expect to have the OPDS menu "keep reading" and so on...

  • OS: Docker

Smartphone (please complete the following information):

  • Device: Samsung Galaxy S24 Ultra
  • OS: Android 14 / One UI 6.1
@GregTroar GregTroar added the bug Something isn't working label May 28, 2024
@aaronleopold
Copy link
Collaborator

Hey 👋 thanks for reporting this! I'll try to take a look this week at what might be happening

@GregTroar
Copy link
Author

thank you so much

@LRotenberger
Copy link
Collaborator

LRotenberger commented May 28, 2024

Hello! I retested my own app and was able to get Stump connected with Moonreader+ on Android. I used the url http://ip:port/opds/v1.2/catalog and then entered login info in the relevant fields after trying to connect to the server. If that still doesn't work you could try out this solution that worked for a couple people: https://www.reddit.com/r/KavitaManga/comments/vsf96f/cant_get_moon_reader_opds_working/?share_id=CCHumGyppVzkxtZdnNDM-&utm_name=ioscss

@GregTroar
Copy link
Author

@LRotenberger Thanks a lot.
I did delete and close the app completely and re added and indeed it worked !!
Thanks a lot

@GregTroar
Copy link
Author

@aaronleopold still cannot make it work in Cantook.

Thanks

@aaronleopold
Copy link
Collaborator

I did delete and close the app completely and re added and indeed it worked !!

Happy that did the trick!

@aaronleopold still cannot make it work in Cantook.

Gotcha, funny enough I actually hadn't heard of that one before you brought it up in the issue. I'll be sure to do some testing with it this week to see what might be happening

@GregTroar
Copy link
Author

Actually it was known before as Aldiko. Probably the best we have used in terms of UI from our side.

@aaronleopold
Copy link
Collaborator

aaronleopold commented May 29, 2024

I'll try and re-validate what I've found so far on Android (my old testing phone is dead right now), but on the surface this seems to be an issue with the Cantook app and not Stump after testing on my iPhone.

The TLDR; is that the app does not seem to correctly parse and/or pass the authorization params you provide in the beginning of the URL as the appropriate request headers. You should be able to reproduce on your end:

  1. Bump the verbosity of your Stump instance to 4 in order to see TRACE level logs

  2. Configure a catalog in Cantook using the same URL pattern: https://username:password@ip:port/opds/v1.2/catalog

  3. Attempt to browse the newly created catalog and observe the error:

    The TRACE log which was emitted was:

    TRACE stump_server::middleware::auth: Checking auth header, is_opds: false, has_auth_header: false, uri: /v1.2/catalog

    The app also shows me additional details about the error it received, which includes a list of headers it sent. The list did not include auth. It also stores this information in plain text since it all exists in the configured URL, seemingly emitting the password in logs/error details, which is an issue in and of itself IMO.

I would try reaching out to the developer of that app in the meantime to see if they would be willing to support authenticated OPDS feeds with explicit configuration, or at the very least parsing legacy login params into request headers.

Like I said though I will try to re-validate my findings on an Android, but if this points to an issue outside of Stump I'm inclined to close it out afterwards. Let me know if you have any questions!

@aaronleopold
Copy link
Collaborator

aaronleopold commented May 29, 2024

I used a bit of a keyword search to try continue figuring this out, and I actually found a reference to authenticated OPDS feeds with Cantook in one of Komga's release notes. So perhaps it is possible! However, a quick glance at the changes referenced reveal it was added to Komga's v2 OPDS API. Cantook doesn't mention what version(s) they support, though.

Regardless, I went ahead and contacted the developer to see what might be going on:

Hi,

I am reaching out on behalf of someone attempting to use Cantook with Stump, OPDS-compatible software which I maintain.

They reported integration issues between our software, and I was able to reproduce their issues. It seems that Cantook does not properly support authenticated OPDS feeds. The conversation and details are publicly available on GitHub: #346.

Could you perhaps guide us toward the appropriate path if authenticated OPDS feeds are in fact supported? Or, if not, is this something that will be added in the future? I'd like to be able to provide people with the most up-to-date information on what 3rd-party applications they can use.

I appreciate your time!

@aaronleopold aaronleopold changed the title [BUG] OPDS Reader Android issues [BUG] Cantook OPDS Reader issues May 29, 2024
@GregTroar
Copy link
Author

Thanks a lot for your time, did you get any answer ?
Thanks
Anyway I can use with MoonReader+ so I am fine :)

@aaronleopold
Copy link
Collaborator

Thanks a lot for your time, did you get any answer ?

No problem! I haven't gotten a response yet, but I'll be sure to post an update here if/when I do

@GregTroar
Copy link
Author

Unfortunately after installing Moonreader+ on my tablet and adding stump catalog it asks for my credentials and after I put them it asks for credentials again and seems to be stuck in the login loop.

No log on stump docker nothing is showing :(

@aaronleopold
Copy link
Collaborator

aaronleopold commented Jun 3, 2024

Unfortunately after installing Moonreader+ on my tablet and adding stump catalog it asks for my credentials and after I put them it asks for credentials again and seems to be stuck in the login loop.

I assume you've already done the fix from before, without success?

If so, can you create another issue with your device details to track it separately?

No log on stump docker nothing is showing :(

If no longs are showing on the Stump side, generally that means either:

  1. The app isn't issuing any requests / the requests aren't reaching your server
  2. The verbosity is not high enough to emit request-level traces

https://www.stumpapp.dev/guides/configuration/server-options#stump_verbosity

@GregTroar
Copy link
Author

Ok here is the log: (trace log and I also added the environment variable that it is in a docker)
Seems like it is not recognizing that it is an OPDS, is_opds showing false

2024-06-04T02:56:42.633122Z TRACE stump_server::middleware::auth: No session found, checking for auth header
at apps/server/src/middleware/auth.rs:66
in tower_http::trace::make_span::request with method: GET, uri: /opds/v1.2/catalog, version: HTTP/1.1
2024-06-04T02:56:42.633134Z TRACE stump_server::middleware::auth: Checking auth header, is_opds: false, has_auth_header: false, uri: /v1.2/catalog
at apps/server/src/middleware/auth.rs:77
in tower_http::trace::make_span::request with method: GET, uri: /opds/v1.2/catalog, version: HTTP/1.1
2024-06-04T02:56:42.633177Z DEBUG tower_http::trace::on_response: finished processing request, latency: 0 ms, status: 401
at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.4.4/src/trace/on_response.rs:114
in tower_http::trace::make_span::request with method: GET, uri: /opds/v1.2/catalog, version: HTTP/1.1

@GregTroar
Copy link
Author

I seem to be very unlucky :(
Trying Chunky Reader on my wife's ipad and no luck as well with OPDS, login and pass are correct

2024-06-04T14:10:08.001968357Z 2024-06-04T14:10:08.001843Z DEBUG tower_http::trace::on_request: started processing request
2024-06-04T14:10:08.001992468Z at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.4.4/src/trace/on_request.rs:80
2024-06-04T14:10:08.001996918Z in tower_http::trace::make_span::request with method: GET, uri: /opds/v1.2/catalog, version: HTTP/1.1
2024-06-04T14:10:08.002001148Z
2024-06-04T14:10:08.002004648Z 2024-06-04T14:10:08.001922Z TRACE stump_server::middleware::auth: No session found, checking for auth header
2024-06-04T14:10:08.002023928Z at apps/server/src/middleware/auth.rs:66
2024-06-04T14:10:08.002027768Z in tower_http::trace::make_span::request with method: GET, uri: /opds/v1.2/catalog, version: HTTP/1.1
2024-06-04T14:10:08.002031608Z
2024-06-04T14:10:08.002035178Z 2024-06-04T14:10:08.001935Z TRACE stump_server::middleware::auth: Checking auth header, is_opds: false, has_auth_header: false, uri: /v1.2/catalog
2024-06-04T14:10:08.002039608Z at apps/server/src/middleware/auth.rs:77
2024-06-04T14:10:08.002043238Z in tower_http::trace::make_span::request with method: GET, uri: /opds/v1.2/catalog, version: HTTP/1.1
2024-06-04T14:10:08.002046708Z
2024-06-04T14:10:08.002054798Z 2024-06-04T14:10:08.001964Z DEBUG tower_http::trace::on_response: finished processing request, latency: 0 ms, status: 401
2024-06-04T14:10:08.002059848Z at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.4.4/src/trace/on_response.rs:114
2024-06-04T14:10:08.002063888Z in tower_http::trace::make_span::request with method: GET, uri: /opds/v1.2/catalog, version: HTTP/1.1

@aaronleopold
Copy link
Collaborator

aaronleopold commented Jun 4, 2024

Are you on nightly for the Stump Docker image? If so, I might know what is happening.

Those logs are actually really helpful, and I should be able to debug what I think might be going wrong after work today. TLDR; in the latest nightly, I reorganized the OPDS router to prepare for V2 support. I think a bug has surfaced from how I re-organized which is stripping the shared opds part of the uri. E.g.:

2024-06-04T14:10:08.002027768Z in tower_http::trace::make_span::request with method: GET, uri: /opds/v1.2/catalog, version: HTTP/1.1
# but then in the middleware function
2024-06-04T14:10:08.002035178Z 2024-06-04T14:10:08.001935Z TRACE stump_server::middleware::auth: Checking auth header, is_opds: false, has_auth_header: false, uri: /v1.2/catalog

@GregTroar
Copy link
Author

Yes nightly :)
Hope you can solve it so I can switch to stump!!

@aaronleopold
Copy link
Collaborator

Thanks for confirming! If it is the bug I outlined above, it should be easy to surface and fix locally. I'll report back once I verify today

If you're looking for a little more stability while using Stump, in general, I'd recommend swapping to the versioned releases in the future. nightly images are automated and less tested. There might be a migration missing between the current latest tag and nightly, so once the next version goes out would be the time if you wanted

@GregTroar
Copy link
Author

I will try latest tag now. No big deal to start from scratch as the setup takes a couple of minutes.

Will see if then it works on chunky and also on moonreader.

@aaronleopold
Copy link
Collaborator

@GregTroar I have put up a PR which contains a tentative fix #350. Once nightly goes out, assuming you haven't already moved to a versioned release, would you be able to re-test and confirm whether the new issue has been resolved? If is isn't resolved, I'll open a separate issue and move the conversation there so this ticket can remain focused on Cantook integration issues.

I also want to note, I wasn't able to test on an Android device (or specifically the MoonReader app). However, I was able to validate in the browser that the OPDS authentication was in fact broken and the changes in the PR resolved the issue.

@GregTroar
Copy link
Author

I did not switched yet as it was very late yesterday night for me :) I am in Asia.

Thanks I will try on the nightly.

Thanks for all your help.

aaronleopold added a commit that referenced this issue Jun 7, 2024
Essential work started towards fixing #346
@aaronleopold
Copy link
Collaborator

@GregTroar I wanted to check in and see if you've had a chance to validate the changes?

Also, while working on V2 OPDS support I believe I successfully implemented the required auth flow to support Cantook:
IMG_4146

So you should be able to use the app once OPDS V2 support is finished. You can track it separately here: #311

@GregTroar
Copy link
Author

Sorry for the delay.

on my side it is still not working in Cantook what is the url ? is it /opds/v2/catalog ? I also tried with v1.2 but still seeing the xml code rather than the books.

The normal version works with Moonreader and is what i am currently using.

@aaronleopold
Copy link
Collaborator

No worries! It won't work with Cantook, I mentioned another issue in my previous message which will come with Cantook support.

I was asking about MoonReader, I'm happy it's working for you

@aaronleopold
Copy link
Collaborator

A 'fix' for Cantook issues is inbound shortly, sometime over the upcoming weekend most likely. The 'fix' was really to support OPDS V2: #367

There are a couple of issues which seem to be on Cantook's side of things, e.g. cover images and labels, but otherwise I tested authentication, feed exploration, and book downloading/reading with no problem 🙂

@aaronleopold
Copy link
Collaborator

aaronleopold commented Aug 4, 2024

OPDS V2 (experimental) support is now available in the experimental docker image. I'm going to close this ticket out. If any Cantook issues surface, feel free to create a separate, targeted issue to address it 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants