Repository navigation
feat(clients): Python + Go client SDKs (C1: M1+M2 clients, M3 release wiring, M4 docs) - #65
Conversation
- client-sdk-facility-design.md v1.2: addendum section 11 (generator field-validation, PyPI naming collision -> authforge-oauth2 dist name, layout finalization, auth injection seams, drift-gate placement, release wiring corrections incl. Go nested-tag requirement) - move design doc todo/ -> in-progress/ (Layer 2 now started), fix all inbound references - new client-sdk-implementation-plan.md: W1-W6 work items with acceptance criteria; incorporates code-architect review findings (5 blocking fixes, 6 improvements)
Cross-platform single script (repo tools convention: --selftest, exit 0/1/2, ASCII tags) that regenerates clients/python + clients/go from apps/server/openapi.yaml with pinned generators and, with --check, diffs against the committed trees (newline-normalized for Windows autocrlf checkouts). --version-only guards the pyproject <-> cmake version linkage (release backstop). Selftest covers tree-diff fault injection, version parse/sync, and ignore filters.
…ten auth layer - clients/python: distribution authforge-oauth2 (import name authforge); src/authforge/generated/ regenerated from openapi.yaml (157 files, openapi-python-client 0.29.0, DO NOT EDIT) - m2m.py: ClientCredentialsAuth/AsyncClientCredentialsAuth (httpx.Auth) with proactive refresh (clock-skew margin), single 401-triggered retry, thread/asyncio-safe locking; m2m_client/async_m2m_client factories inject into the generated AuthenticatedClient via set_httpx_client (bypasses its static bearer header); basic_auth_client for introspect/revoke (F-017 client_secret_basic); one-shot fetch_client_credentials_token - oauth.py: AuthorizationCodeFlow (authorize URL + PKCE S256 + code exchange + refresh rotation helper), RFC 7636 appendix B vector tested - openapi.yaml: OAuth2Error enum += invalid_token, insufficient_scope (RFC 6750 section 3.1 codes the userinfo 401/403 responses already documented; without them the generated client cannot parse real 401s). oasdiff verdict: warnings only (response-property-enum-value-added), 0 breaking errors - unit tests 25 green (MockTransport, no server); integration suite env-gated (AUTHFORGE_BASE_URL)
…auth layer - clients/go: module github.com/lucaswang420/authforge/clients/go (go 1.24; oapi-codegen/runtime v1.7.0); generated/client.gen.go regenerated from openapi.yaml (oapi-codegen v2.8.0, DO NOT EDIT) - auth/clientcredentials.go: NewM2MClient (x/oauth2 clientcredentials, AuthStyleInHeader per F-017 -- cached + auto-refresh + goroutine-safe), FetchClientCredentialsToken one-shot, NewBasicAuthClient for introspect/revoke (RFC 7662 2.1 calling-client Basic) - auth/authcode.go: AuthCodeFlow (authorize URL + PKCE S256 + exchange + refresh, confidential Basic / public form client_id), TokenResponse, ParseAuthorizationResponse - auth/pkce.go + auth/errors.go: RFC 7636 helpers; AuthError unwraps x/oauth2 RetrieveError into the RFC 6749 error body - unit tests green (httptest: G1-G8 matrix incl. concurrency caching, 1 s-expiry auto refresh, RFC 7636 appendix B vector, Basic-on-exchange); integration suite behind -tags integration + AUTHFORGE_BASE_URL
…(M3 wiring, M4) - clients-sdk.yml (new): PR path-filtered drift gate + unit tests for both clients (python: pinned generator + pytest; go: build/vet/gofmt + tests); kept out of static-checks (source-only) per design 11.5 - release.yml: new sdk-python job (version-linkage backstop, sdist+wheel always; PyPI publish tag+secret gated via job env + step if -- the secrets context cannot drive a job-level if); github-release job now pushes the nested clients/go/v<version> tag Go module resolution requires (subdirectory modules are invisible to root tags) - README.md / README.zh-CN.md: 'Path D -- Client SDKs' section - next-phase-implementation-plan.md: C1 marked delivered with deviations (PyPI naming, nested tags, OAuth2Error enum fix); progress-status.md, productization-evolution README index, design doc AC table (AC4-AC6 evidenced, AC7 explicitly pending publish)
…esearch link The doc-link checker caught 5 links my earlier path rewrites got wrong (../in-progress/ from same-directory files, sibling governance-plan link after the move) plus the pre-existing ../productization-research.md typos in productization-evolution-plan.md; remaining 2 broken links are local .zcode session artifacts, out of repo scope.
The YAML now feeds clients/python + clients/go; the skill workflow (and its three tool mirrors) tells editors to run the regen tool after spec edits and keep the pyproject/cmake version linkage in mind on bumps.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
The auth layer keeps a private httpx client for token I/O (separate on purpose, so token fetches never recurse through auth_flow); closing only the returned AuthenticatedClient leaked that pool until GC -- the async flavour leaked transports on a possibly-closed loop. The generated attrs classes are slotted, so close_m2m_client()/close_async_m2m_client() reach the auth object through the injected client's .auth field and close both pools. Tests assert both pools report closed; README and design doc 11.4 document the semantics.
Self-review outcomeA code-reviewer pass over the handwritten surfaces (Python auth layer + tests, Go auth package + tests, regen tool, both workflows, packaging) came back with one high-confidence finding, fixed in 5cae993:
Everything else was verified clean, notably: httpx sync CI so far: clients-sdk (python+go), static-checks, frontend, oasdiff, security — all green; the three C++ build-test matrix jobs are running (this PR does not touch C++ sources). |
…r slowness; master average ~20m, this PR changes zero C++ build inputs)
…een) - clients-sdk.yml + release.yml pass actionlint v1.7.12 with zero findings; release.yml is tag-triggered so CI never parsed it on this branch -- static validation closes that gap - both Client SDKs jobs verified SUCCESS on PR #65 checks - W5 dispatch dry-run box stays open: pre-merge dispatch attempt was rejected (PAT lacks Actions write, 403); post-merge dispatch from the Actions UI remains the plan, publish-step skip logic is static-gated (ref_type == 'tag' && secret) so dispatch cannot publish
Frontends' package.json synced to 1.3.0 (the cmake/CMakeLists/conanfile/ pyproject/openapi bumps landed with PR #68); CHANGELOG curated for the two mainlines since v1.2.0: C1 client SDKs (Python authforge-oauth2 + Go, PR #65) and B2 social account link/unlink (PR #68). 21 commits, purely additive minor.
Summary
Implements task C1 (next-phase plan, third tier): the Python + Go client SDKs (design M1-M4), on top of the merged M0 spec governance (v1.2.0).
clients/python): generated typed surface (openapi-python-client 0.29.0, 157 files, DO-NOT-EDIT) + handwritten auth layer —m2m_client/async_m2m_client(client_credentials with proactive refresh + one 401-triggered retry, thread/asyncio-safe),basic_auth_client(introspect/revoke per RFC 7662 §2.1), one-shotfetch_client_credentials_token,AuthorizationCodeFlow+PkcePair(S256). Distribution nameauthforge-oauth2, import nameauthforge.clients/go): oapi-codegen v2.8.0 generated client +authpackage —NewM2MClient(x/oauth2 clientcredentials,AuthStyleInHeaderper F-017),FetchClientCredentialsToken,NewBasicAuthClient,AuthCodeFlow/PKCE. Modulegithub.com/lucaswang420/authforge/clients/go.tools/clients/regen_clients.py(pinned generators,--check, version-linkage--version-only,--selftest) + newclients-sdk.yml(path-filtered; python/go jobs with drift + unit tests; kept out of source-only static-checks).release.ymlgainssdk-python(version backstop + build always; PyPI publish tag+secret gated via job-env + step-if — thesecretscontext cannot drive a job-levelif) and pushes the nestedclients/go/v<version>tag on release (subdirectory modules are invisible to root tags).clients/python/examples/client_credentials_demo.py), design addendum §十一 + implementation plan with acceptance criteria (both indocs/productization-evolution/in-progress/).Design deviations found by field validation (all documented in §十一)
authforgeandauthforge-sdkon PyPI are taken by unrelated projects → distributionauthforge-oauth2(importauthforge).clients/go/v<version>.OAuth2Errorenum lackedinvalid_token/insufficient_scope(RFC 6750 §3.1 codes that userinfo 401/403 actually return per the YAML's own descriptions) — generated clients crashed parsing real 401s. oasdiff verdict: 24 warnings, 0 breaking errors (enum widening).api-reference.mdalready documented these codes; the YAML now matches.Review
Design + plan were deep-reviewed by a code-architect pass (findings recorded in the implementation plan's appendix): 5 blocking issues fixed before implementation (nested Go tags, issuer fallback assertion, server-boot recipe, secrets-context gating, release-time version backstop), 6 improvements adopted.
Verification
--check)python -m build clients/pythonrelease.yml+clients-sdk.yml)Versioning
No version bump in this PR (repo convention: separate
chore(release)commit + tag).clients/python/pyproject.tomlstays at 1.2.0 == cmake (enforced by the new gates). After merge, release v1.3.0 (minor: new clients) via the usual flow.Follow-ups (out of scope)
authforge-oauth2, addPYPI_API_TOKENrepo secret (the release job prints this hint when the secret is absent). AC7 publish smoke belongs to that release./oauth2/tokendescription mentions body-form client credentials while F-017 restricts that toclient_secret_postclients — candidate follow-up spec clarification.release.ymldry-run dispatch (workflow_dispatch) to watch sdk-python skip-on-missing-secret, after merge.