fix(socrate): RegisterUser and GetUserAsService call the service-account routes - #61
Merged
Merged
Conversation
…unt routes
Both methods sent a client_credentials token to /api/apps/{id}/users...,
routes that need an app admin's user token, so Socrate answered 401.
RegisterUser now posts to /api/apps/{id}/service/users (Name still sent).
GetUserAsService now reads GET /api/apps/{id}/service/users/{user_id}
(added in the Socrate release after v1.5.3); it returns nil, nil only for
Socrate's own JSON 404 and an error for a router 404, so a missing route
is never read as "no such user". No exported identifier changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GKRxaeYxyDhmt42cehLsGA
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
socrate.Client.RegisterUserandGetUserAsServicesent aclient_credentialstoken to/api/apps/{id}/users…. Those routes need an app admin's user token, so Socrate answered401 invalid token claimsand neither method ever worked.RegisterUsernow posts toPOST /api/apps/{id}/service/users, the service-account routeInviteUserAsServicealready uses.Nameis still sent; Socrate accepts it.GetUserAsServicenow readsGET /api/apps/{id}/service/users/{user_id}. That route is added in ovander/go-oauth2 (separate PR) and arrives in the Socrate release after v1.5.3.nil, nilonly for Socrate's own JSON 404 (not a member of the app, or no such user).How it was tested
New
socrate/service_user_routes_test.go, against a fake Socrate whose user-token routes answer a service token with 401, as the real one does:RegisterUserhitsPOST /api/apps/3/service/userswith the service bearer and the full body;GetUserAsServicehitsGET /api/apps/3/service/users/7;nil, nil;The existing
GetUserAsServiceand attribution tests now point at the new path.go mod tidy && git diff --exit-code go.sumleavesgo.sumunchangedgo build ./...passesgo vet ./...passesgo test -race -count=1 -timeout=120s ./...passesgolangci-lint run ./...(v2.14.0) reports no issuegovulncheck ./...: couldn't run in the sandbox (vuln.go.dev returns 403); CI runs itA line is added under
## [Unreleased]inCHANGELOG.mdCompatibility
GetUserAsServiceneeds a Socrate that has the new route; against an older one it returns an error, where it used to return a 401 error.🤖 Generated with Claude Code
https://claude.ai/code/session_01GKRxaeYxyDhmt42cehLsGA
Generated by Claude Code