Skip to content

feat: add org apps connect and authorize commands#88

Merged
guyb1 merged 1 commit into
mainfrom
feat/org-apps-connect
Jul 4, 2026
Merged

feat: add org apps connect and authorize commands#88
guyb1 merged 1 commit into
mainfrom
feat/org-apps-connect

Conversation

@guyb1

@guyb1 guyb1 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

What

Two new commands in the org apps group, wrapping the canonical org-level connect endpoints:

  • onecli org apps connect --provider X --field k=v [--json …] [--label …] [--connection-id …] [--method …] [--dry-run] — connect an app at the organization level with direct credentials (API-key apps). The connection is shared by every project in the org. Dry-run masks all credential values.
  • onecli org apps authorize --provider X [--connection-id …] — start the org-scoped OAuth flow and print {"authorizeUrl": …} captured from the redirect Location (never follows it, never opens a browser — the hint tells the agent/user to open it).

Client methods: ConnectOrgApp (POST /v1/org/apps/{provider}/connect) and OrgAppAuthorizeURL (GET /v1/org/apps/{provider}/authorize with a no-redirect client, resp.Location() resolution, and the legacy /api prefix fallback preserved). Plus: hand-maintained help.go catalog entries, a compact README Organization section (the org group was previously undocumented), and a fix for the stale default host in the README (app.onecli.shapi.onecli.sh, matching internal/config).

Auth is the organization API key (oc_org_…) as a plain bearer — no extra headers; the org is derived from the key.

Verification

  • go build, go test -race ./..., golangci-lint run (0 issues), gofmt clean.
  • New httptest coverage: connect method/path/auth/body incl. all contract fields, authorize Location capture without following, legacy /api prefix rewrite, empty connectionId omitted from the query, error paths, and buildConnectFields (json+flag merge, connect-scoped empty error).
  • Exercised live against a self-hosted Enterprise container running the server branch: org connections list, org apps connect --dry-run, org apps authorize all returned the expected JSON.

Review

Reviewed via this repo's own skills, each SKILL.md read in full: agent-first-cli (output/exit-code/dry-run/input-hardening contracts), golang-patterns, golang-pro (MUST-list walked). 5 findings fixed: resp.Location() instead of the raw header (+ dead clause), --connection-id validated at the command boundary, a connect-specific empty-fields error via a shared mergeCredentialFields core, url.PathEscape on the new client paths, and the test coverage above. Help catalog verified flag-for-flag against the Kong structs; README verified line-by-line against the real commands.

Related PRs (merge order)

Server-side surface: https://github.com/onecli/onecli-cloud/pull/625 (must be deployed first — these commands 404 against older servers, surfacing as a normal not-found error with exit code 3). SDK sibling: onecli/node-sdk#45. Docs: https://github.com/onecli/onecli-docs/pull/6 (lands last).

🤖 Generated with Claude Code

Connect apps at the organization level with direct credentials
(POST /v1/org/apps/{provider}/connect) and start org-scoped OAuth flows by
printing the captured authorize URL (GET /v1/org/apps/{provider}/authorize,
redirects never followed). Org connections are shared by every project;
auth is the organization API key as a plain bearer. Includes help catalog
entries, a README Organization section, and the corrected default API host.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@guyb1
guyb1 force-pushed the feat/org-apps-connect branch from f2fa848 to a7283d7 Compare July 4, 2026 22:10
@guyb1
guyb1 merged commit e5b75db into main Jul 4, 2026
2 checks passed
@guyb1
guyb1 deleted the feat/org-apps-connect branch July 4, 2026 22:12
@guyb1 guyb1 mentioned this pull request Jul 4, 2026
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.

1 participant