mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-09 14:53:00 +03:00
🐛 Bug Report: API key authentication does not work #295
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jonasclaes on GitHub.
Reproduction steps
X-API-KEYheaderExpected behavior
A response with the requested resources is returned.
Actual Behavior
The following error is returned from the backend.
Version and Environment
v0.40.0
Caddy, outside of the container
I've investigated in the source, I think I know where the issue is coming from.
When passing an
Authorizationheader with the contents asBearer xyz, where xyz is a valid token used in the frontend, the authentication to the API succeeds.When trying with the
X-API-KEY, and the value set to the generated API key, the auth fails.The logic in the
auth_middleware.gofile seems correct to me, however, the JWT auth function comes first, and I think these lines may cause the request to fail, even if the API key is correct?348192b9d7/backend/internal/middleware/jwt_auth.go (L25-L26)I'm assuming the issue is right there, however, I'm not sure how we could easily fix that without refactoring the auth middleware.
Log Output
Error #01: You are not signed in@stonith404 commented on GitHub:
Fixed in
v0.40.1.@kmendell commented on GitHub:
I think this is oversight on the Auth header, ill take a look at this and see if i can find a fix for it.
@jonasclaes commented on GitHub:
Thanks for the quick fix guys! :D