Skip to content

fix(auth): accept Authorization: Bearer <token> as well as the bare token - #7

Merged
inkly merged 3 commits into
ReCasaOS:mainfrom
ppenguin:feat/bearer-authorization
Oct 24, 2026
Merged

inkly merged 3 commits into
ReCasaOS:mainfrom
ppenguin:feat/bearer-authorization

Conversation

@ppenguin

Copy link
Copy Markdown
Contributor

Part of ReCasaOS/CasaOS#46 (helper: ReCasaOS/CasaOS-Common#7, released in v0.4.31).

  • v1, v2 extractors: jwt.TokenFromAuthorization on the Authorization value → bare token (unchanged) or Bearer <token> (scheme case-insensitive)
  • raw header still decides: Internal <secret> (skipper), header vs ?token= (v1); the helper's output only feeds the token check
  • Common v0.4.27 → v0.4.31 (go.mod only)
  • tests: bare, Bearer, bearer → accepted; Basic, Bearer alone → 401

🤖 Generated with Claude Code

ppenguin and others added 3 commits October 23, 2026 14:38
- was: the whole Authorization value taken as the JWT → `Bearer <token>` (RFC 6750; OpenAPI `bearer`, curl `--oauth2-bearer`) → 401
- now: token lookup through CasaOS-Common `jwt.TokenFromAuthorization`: bare unchanged, `Bearer` stripped (case-insensitive), `Internal <secret>` untouched
- needs: CasaOS-Common `feat/bearer-authorization` released → bump go.mod
- test: /v1/users/current with bare, Bearer, bearer → 200; Basic → 401

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ests

- Common v0.4.31: `jwt.TokenFromAuthorization` (released, ReCasaOS/CasaOS-Common#7)
- tests: bare, `Bearer`, `bearer` → accepted; `Basic`, the scheme alone → 401

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@inkly inkly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, we reviewed all eight together. The raw header still makes every decision (empty vs ?token=, header-only, Internal <secret>); the helper only feeds the token check, and the gateway's proxying is unchanged. The v0.4.31 bumps are tidy with matching go.sum, and builds and route tests pass, also merged with CasaOS#55 and CasaOS-UserService#6. Approving. We'll squash-merge with a plain commit message.

Optional follow-ups, not blocking: a loopback Bearer Internal <secret> → 401 case in core's tests (LocalStorage and VirtManagement write a secret no case uses), a v1 case in AppManagement and a v2 case in UserService.

@inkly
inkly merged commit de67b19 into ReCasaOS:main Oct 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants