miharekar / visualizer

A visualizer for .shot files
https://visualizer.coffee/
MIT License
97 stars 11 forks source link

Cannot update shots from Beanconqueror #113

Closed uyuarasy closed 3 weeks ago

uyuarasy commented 3 weeks ago

There's a basic auth integration in Beanconqueror (v7.5.0, iOS 18.0.1) what was worked 2-3 days ago, now I'm getting a 401 response:

{
  "status": 401,
  "headers": {
    "cf-cache-status": "DYNAMIC",
    "x-runtime": "0.006702",
    "server": "cloudflare",
    "cache-control": "no-cache",
    "strict-transport-security": "max-age=63072000; includeSubDomains",
    "referrer-policy": "strict-origin-when-cross-origin",
    "alt-svc": "h3=\":443\"; ma=86400",
    "report-to": "{\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v4?s=ySPvaw62F2%2B5J88%2Fc81F30qU0U6Dc7DsVHQzYnVTzCquwJwuCPrAPAKLb299Vo0IJ2gj3N221NVZBszXCMpSS1ZBULlj7hkmwIEAYAmCE5ut0FdNrz3eWLbsgNIsveEUY6K%2BDcpWzn2w5HAqbxf6hA%3D%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}",
    "server-timing": "cfL4;desc=\"?proto=QUIC&rtt=174624&sent=46&recv=72&lost=0&retrans=0&sent_bytes=4880&recv_bytes=75384&delivery_rate=56&cwnd=12000&unsent_bytes=0&cid=baadb41532e1d03d&ts=1010&x=1\", cfExtPri, cfHdrFlush;dur=0",
    "priority": "u=3,i",
    "vary": "Accept-Encoding",
    "x-xss-protection": "0",
    "date": "Fri, 25 Oct 2024 11:53:17 GMT",
    "x-request-id": "46cb950e-f23c-470d-b5f5-12ce211801ec",
    "nel": "{\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}",
    "x-frame-options": "SAMEORIGIN",
    "x-cache": "bypass",
    "content-type": "text/html",
    "cf-ray": "8d8201596b1081e8-IAD",
    "x-content-type-options": "nosniff",
    "x-permitted-cross-domain-policies": "none"
  },
  "url": "https://visualizer.coffee/api/shots/upload",
  "error": ""
}

Opened an issue in their Discord first, but was informed it seems like an error on Visualizer end.

miharekar commented 3 weeks ago

401 error means unauthorized, so it means you don't have the correct username/password set in Beanconqueror.

Go to Menu -> Settings and scroll down to Visualizer and re-enter your username (email) and password.

uyuarasy commented 3 weeks ago

Forgot to mention my credentials are valid. Copied from password manager then typed by hand, getting the same error every time. It works when I login from a browser.

miharekar commented 3 weeks ago

I don't know what to tell you, but they're not 😅 Maybe you have some whitespace somewhere. Also, goes without saying, but password is case sensitive.

The code is trivial and didn't change for ages: https://github.com/miharekar/visualizer/blob/main/app/controllers/api/base_controller.rb#L21-L26

What I added just now (after seeing your issue) is downcasing email, so that field is no longer case-sensitive.

uyuarasy commented 3 weeks ago

Thanks for the quick replies, I'll try to debug then what could be the issue... 😄 Just tried out your REST API, fetched my previous shot without any issue. It looks like an invalid cred. issue indeed, as connection check (https://github.com/graphefruit/Beanconqueror/blob/master/src/services/visualizerService/visualizer-service.service.ts#L150) also fails, but it doesn't make any sense why...

miharekar commented 3 weeks ago

Looking at BQ code, it is pretty naive:

https://github.com/graphefruit/Beanconqueror/blob/master/src/services/visualizerService/visualizer-service.service.ts#L155

Does your password include a : by any chance? 🤔

uyuarasy commented 3 weeks ago

Unfortunately it doesn't. The only special character is an exclamation mark, the rest are lower and upper-case letters and numbers.

Base64 encoded my plain text credentials based on how BQ does it and tried out in Postman, works as expected. Can it be some ioinc-related issue? Prob. this should be a question in the other thread... :)

miharekar commented 3 weeks ago

Thanks for debugging with me @uyuarasy, I've made a silly mistake when refactoring 🤦‍♂️