Skip to content

feat(core): sign in to a company server and verify its license - #4470

Merged
datlechin merged 23 commits into
mainfrom
feat/core-account-company-server
Nov 25, 2026
Merged

datlechin merged 23 commits into
mainfrom
feat/core-account-company-server

Conversation

@datlechin

@datlechin datlechin commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Summary

  • tablepro-account resolves the server: an OS-managed URL that allows no other, else the person's choice, else the managed default, else tablepro.app. Https only; http to a loopback host in development builds. The choice lives in account-server.json beside account.json.
  • A company server is found through RFC 9728 metadata (resource must be the origin) and OIDC discovery (issuer must match, never tablepro.app's) when a run first needs it and at each sign-in; never kept on disk. OAuth endpoints on the issuer's origin, jwks_uri on the API's; no redirects; every answer read before the license verifies is capped.
  • License chain: GET /v2/license verified offline against the compiled release license keys (current Yo4CIBJnxzUMSLPnsLId8ngVVe5xuZgHkOU9Z-Hgo04, next J5yCP_8iTKHyXvyYQ9y4-D2-Z_U4hbtGDvwkfzv57R0) in tablepro-cloud's check order, with grace_until (ADR 0046). Entitlements verify only with the JWKS the license admits, iss the API origin, features cut to the license; past grace_until only team_library works. Nothing else of a company server's API is read before its license verifies.
  • License and JWKS are kept in account.json, bound to the sign-in by an HMAC keyed with the refresh token; a new license applies to the held entitlement at once.
  • A company sign-in keeps its issuer and its refresh token goes to no other; access tokens whose aud is not the company API are refused.
  • Every entitlement's iss is checked, tablepro.app's too.
  • An RFC 9207 iss in the authorization response is compared when present (not yet required: tablepro-cloud does not send it).
  • Mac seams: AppClient::MACOS signs in through a new HostWebAuthenticator (custom scheme, state check, cancel, superseded attempts revoked; cancel() closes the host's session when the core stops waiting); the host passes its own 64-hex machine ID; one refresh token item per server (SecretItemTag::AccountRefreshTokenFor, tablepro.app keeps AccountRefreshToken); RFC 8693 license-key exchange (never sent to a company server); the Mac's Keychain sign-in and Account/entitlement.jwt are adopted while account.json is missing, an offline file imported without sign-in stays an offline file.
  • Shared links are read from tablepro.app whatever server is signed in. Retry-After past a day reads as a day; token lifetimes are capped.
  • FFI: AccountConfig gains client, machine_id, managed_server_url, allow_other_servers, legacy_entitlement_file, license_keys; account_url, api_url, entitlement_keys and license_keys are refused in release builds. New server(), choose_server, access_token, access_token_rejected, use_license_key, import_offline_file, license(), and AccountListener::signed_out(cause).
  • ServerSettings::Fixed is one server for good (Linux's tablepro.app, a development stack); Account::new, with one refresh token item, takes only a fixed server.
  • Windows bindings regenerated; SecretItem becomes a record with the sign-in key. Linux passes ServerSettings and words the new errors.
  • ADR 0047, the Apple apps sign in through the core; 0016 and 0026 amended.
  • /v2 document and license vectors copied from tablepro-cloud main (after TableProApp/cloud#30); update-cloud-api.sh now copies the license vectors too.

Tests changed on purpose:

  • core/crates/ffi/tests/account.rs: a development stack's entitlements name its API origin as iss, and its refresh token is kept under AccountRefreshTokenFor.
  • windows/tests/TablePro.Interop.Tests/AccountTests.cs: AKeptSignInAsksTheHostForTheRefreshTokenItem becomes AKeptSignInAsksTheHostForItsServersRefreshTokenItem, and the share test stores the token under the stack's keyed item.
  • core/crates/ffi/src/host.rs, the_account_s_refresh_token_is_an_item_of_its_own: goes through the per-server vault.
  • core/crates/ffi/tests/account.rs: builds only with debug assertions, since a release core refuses the local stack every test signs in to.

Test plan

  • tablepro-account (167, debug and --release as the Linux packages run it): resolution precedence, origin parsing, discovery mismatches, every license vector and grace boundary, JWKS cut and iss mismatch, company sign-in and restore, substituted keys and kept discovery ignored, license downgrades, issuer and audience binding, 429 and lifetime caps, cancel during discovery, web-authenticator sign-in, license-key exchange, legacy adoption, server change.
  • tablepro-ffi: release build refuses the overrides, Mac config, per-server items, web session round trip.
  • TableProFFI Swift tests on a release core; Windows TablePro.Interop.Tests; Linux account and FFI tests and lint in the Linux container.

@datlechin
datlechin enabled auto-merge (squash) November 24, 2026 06:12
…pany-server

# Conflicts:
#	core/crates/ffi/src/core_handle.rs
#	scripts/ci/detect-changed-paths.sh
#	scripts/ci/test_detect_changed_paths.py
#	windows/src/TablePro.Interop/Generated/tablepro_ffi.cs
@datlechin
datlechin disabled auto-merge November 25, 2026 03:30
@datlechin
datlechin merged commit 8955f77 into main Nov 25, 2026
44 of 46 checks passed
@datlechin
datlechin deleted the feat/core-account-company-server branch November 25, 2026 03:30
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