Mark currently accessing token in oauth token management API #8059
No reviewers
Labels
No labels
AP C2S
AdminAPI
Breaking API
Breaks existing config
Check if still valid
Data Protection
Do not merge
Document in the changelog
Doing
Feature Request / Enhancement
MastoAPI
NL2
NL4
OStatus
OTP Releases
Refactor
Security
To Do
TwitterAPI
bug
complicated
confirmed
deps
discussion
documentation
easy
feature: to be merged in stable
fix: to be merged in stable
incident
needs to be backported to maint
needs-changes
needs-info
needs-review
performance
regression
unclear
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
pleroma/pleroma!8059
Loading…
Reference in a new issue
No description provided.
Delete branch "oauth-mark"
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?
Essential thing for when managing your access tokens. Otherwise it's extremely easy to revoke your own token and accidentaly log yourself out.
Checklist
changelog.ddirectory, create a file named<code>.<type>./oc review
opencode-agent:job=171:generation=1
Verdict
GET /api/oauth_tokensreturns 500 for every request on this head. I rantest/pleroma/web/o_auth/token_controller_test.exsagainst the exact head commit: 11 tests, 3 failures — every test that hits the list endpoint fails withPhoenix.Template.UndefinedError(Assigned keys: [:user, :tokens, :token, ...]).P1:
current_tokenassign never reaches the view, so the endpoint always 500sTwo halves of one root cause:
lib/pleroma/web/o_auth/token_controller.ex:33renders with the keytoken:, but the"index.json"clause inlib/pleroma/web/o_auth/token_view.ex:8matches oncurrent_token:. No clause matches, so rendering raises and the action fallback returns 500.token_view.ex:10callsrender_many(Pleroma.Web.OAuth.TokenView, "show.json")with no extra assigns, so each item is rendered with only%{token: entry}— while the"show.json"clause intoken_view.ex:14requires%{token: _, current_token: _}and would raise the same way one level down.Triggering conditions: any
GET /api/oauth_tokenswith a valid token; the pre-existing"renders list"and"is allowed with the read scope"tests fail along with the new"marks which token is being used for the request"test. Impact: the token-management list (the page this PR exists to improve) is completely unusable, and the newis_current_tokenfield never renders.Smallest correction:
Checked and not raised
OAuthScopesPlughalts with 403 before the action when the token assign is nil, socurrent_token.idcannot seenilhere.TokenView, and the new test itself plus the changelog entry look fine once the plumbing is fixed.Merge readiness: 2/5
One P1 finding (caps the rating at 3/5): the PR's entire feature and the pre-existing list endpoint are broken, but the scope is narrow and the fix above is small. Re-run the token controller tests after fixing.
/oc review
opencode-agent:job=172:generation=1
Verdict
No defects found in this pull request at the reviewed head. The P1 from the prior review (assign-key mismatch making
GET /api/oauth_tokensreturn 500) is fixed: the controller, view, andrender_manyassigns are now consistent.Verification
lib/pleroma/web/plugs/o_auth_scopes_plug.ex,lib/pleroma/web/plugs/o_auth_plug.ex, andlib/pleroma/web/o_auth/token.ex.lib/pleroma/web/o_auth/token_controller.ex:33renders%{tokens:, current_token:}, matchinglib/pleroma/web/o_auth/token_view.ex:8; the view forwardscurrent_tokenthroughrender_many, matching the"show.json"clause atlib/pleroma/web/o_auth/token_view.ex:16.mix test test/pleroma/web/o_auth/token_controller_test.exsagainst the exact head: 11 tests, 0 failures, including the new"marks which token is being used for the request"test.Checked and not raised
OAuthScopesPlughalts with 403 before the action when the token assign is nil, socurrent_token.idcannot seenilhere.TokenView; the only producer of"show.json"assigns is the fixed"index.json"clause.is_current_token, not the token secret; the changelog entry is present.Merge readiness: 5/5
Production-ready with no known findings.