Skip to content

feat(hub): synchronize GitHub authorization - #148

Open
alliscode wants to merge 12 commits into
alliscode-prototype-authorization-layerfrom
alliscode-github-synchronized-access
Open

alliscode wants to merge 12 commits into
alliscode-prototype-authorization-layerfrom
alliscode-github-synchronized-access

Conversation

@alliscode

Copy link
Copy Markdown
Collaborator

Why

GitHub sign-in proves who a user is, but it should not make repository permissions Hub's hard-coded authority. Teams need an explicit way to synchronize qualifying GitHub access while keeping Hub administrators in control and preserving the current repository-based behavior only as an opt-in compatibility mode.

What changes

Hub now stores linked GitHub repositories by immutable repository ID and records synchronized user baselines separately from manual Hub grants and denies. Admission and prototype synchronization are both explicit choices. The earlier repository-scanning behavior remains available as a compatibility mode rather than the default.

Effective prototype access follows one order: explicit Hub deny, explicit prototype or workspace role, a fresh GitHub-synchronized baseline, then no access. Decision explanations identify the source and include the confirmed repository permission when GitHub supplies the baseline. Synchronization never rewrites manual Hub overrides.

Verified GitHub App webhooks mark repository state dirty or removed, while manual and periodic reconciliation use the separately configured installation credentials to confirm current metadata and permissions. Generation checks prevent stale in-flight reconciliation from resurrecting removed access or replacing newer results. During an outage, Hub can use a bounded last-known-good baseline only for the same repository whose live check failed; stale access eventually fails closed.

Artifact ingestion and production OIDC remain separate later layers.

@alliscode
alliscode requested review from a team and nshki as code owners October 28, 2026 18:46
Copilot AI auto review requested due to automatic review settings October 28, 2026 18:46
@alliscode
alliscode added this pull request to stack #122 October 28, 2026 18:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical authorization flaws can reactivate suspended memberships, grant access through the wrong repository, and leave sessions usable after repository deletion.

15 open issues
What changed in this PR

Adds opt-in GitHub authorization synchronization to Hub’s existing sign-in and prototype-access system, storing repository baselines separately from manual Hub grants and denies.

Changes:

  • Adds persistent repository sources, synchronized permissions, webhook deliveries, and audit provenance.
  • Connects admission and prototype policies to verified webhooks and manual or periodic reconciliation.
  • Adds administration APIs, authorization tests, configuration examples, and operating documentation.
File Description
hub/​server/​routes/​types.ts Adds the GitHub authorization route dependency.
hub/​server/​routes/​product/​index.ts Adds the prototype authorization-policy handler.
hub/​server/​routes/​index.ts Registers repository, webhook, and policy endpoints.
hub/​server/​routes/​github-authorization/​index.ts Implements repository administration and webhook handlers.
hub/​server/​routes/​github-authorization/​index.test.ts Covers session forwarding, CSRF, and webhook responses.
hub/​server/​repositories/​security-audits/​types.ts Adds repository-source audit references.
hub/​server/​repositories/​security-audits/​save-audit/​index.ts Persists repository-source audit references.
hub/​server/​integrations/​github/​check-repository-admission/​constants.ts Expands GitHub repository response schemas.
hub/​server/​index.ts Schedules periodic reconciliation.
hub/​server/​domains/​prototype-authorization/​evaluate-access/​types.ts Defines synchronized baseline decision details.
hub/​server/​domains/​prototype-authorization/​evaluate-access/​index.ts Includes GitHub baseline provenance in decisions.
hub/​server/​domains/​prototype-authorization/​evaluate-access/​index.test.ts Tests baseline precedence and explanations.
hub/​server/​domains/​prototype-authorization/​create-service/​types.ts Extends policy mutation and baseline contracts.
hub/​server/​domains/​prototype-authorization/​create-service/​index.ts Integrates baselines, discovery, and policy changes.
hub/​server/​domains/​prototype-authorization/​create-service/​index.db.test.ts Updates baseline fixtures and listing assertions.
hub/​server/​domains/​github-authorization/​map-permission/​index.ts Maps GitHub permissions to Hub baseline roles.
hub/​server/​domains/​github-authorization/​map-permission/​index.test.ts Tests permission mapping and denial.
hub/​server/​domains/​github-authorization/​create-service/​types.ts Defines synchronization service contracts.
hub/​server/​domains/​github-authorization/​create-service/​index.ts Implements admission, reconciliation, webhooks, and repository lifecycle.
hub/​server/​domains/​github-authorization/​create-service/​index.db.test.ts Covers synchronization, isolation, races, outages, and rollback.
hub/​server/​domains/​authentication/​create-service/​types.ts Extends admission policies with baseline persistence.
hub/​server/​domains/​authentication/​create-service/​membership.test.ts Updates the no-admission fixture.
hub/​server/​domains/​authentication/​create-service/​index.db.test.ts Updates the legacy admission fixture.
hub/​server/​domains/​authentication/​create-runtime/​index.ts Wires synchronization into authentication and prototype access.
hub/​server/​domains/​authentication/​create-admission-policy/​index.ts Adds the opt-in synchronized admission mode.
hub/​server/​domains/​authentication/​complete-github-authorization/​index.ts Applies admission results and saves baselines during sign-in.
hub/​server/​domains/​administration/​create-service/​index.ts Updates the internal no-admission dependency.
hub/​server/​create-app/​index.ts Preserves raw webhook bodies and omits payload logging.
hub/​schema/​user.prisma Relates users to synchronized access.
hub/​schema/​security-audit.prisma Adds repository-source audit relations.
hub/​schema/​prototype.prisma Stores prototype authorization mode and source.
hub/​schema/​migrations/​20261027230000_github_synchronized_authorization/​migration.sql Creates synchronization tables, constraints, indexes, and relations.
hub/​schema/​github-webhook-delivery.prisma Models webhook delivery deduplication.
hub/​schema/​github-synchronized-access.prisma Models per-user repository baselines.
hub/​schema/​github-repository-source.prisma Models linked repositories and synchronization state.
hub/​schema/​github-authorization-policy.prisma Models the last-known-good duration.
hub/​README.md Updates the implemented-feature overview.
hub/​docs/​testing-and-operations.md Describes synchronization coverage and operations.
hub/​docs/​README.md Adds the integration guide to the index.
hub/​docs/​prototype-authorization.md Documents baseline precedence and lifecycle.
hub/​docs/​membership-and-administration.md Documents synchronized membership and administration endpoints.
hub/​docs/​identity.md Explains admission modes and credential separation.
hub/​docs/​github-integration.md Documents repository synchronization and outage behavior.
hub/​docs/​database.md Describes synchronization records and persistence boundaries.
hub/​docs/​architecture.md Updates system capabilities and runtime composition.
hub/​.env.example Documents admission modes and the webhook secret.

Review effort: Max (auto)

@alliscode
alliscode force-pushed the alliscode-github-synchronized-access branch from ebe0486 to e03c3a4 Compare October 28, 2026 21:08
@alliscode
alliscode requested an auto review from Copilot October 28, 2026 22:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical authorization flaws permit access through disproved, expired, or installation-mismatched grants, while migration defects can break compatibility sign-in and remove existing memberships and sessions.

11 open issues
15 resolved since last review

Review effort: Max (auto)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alliscode
alliscode force-pushed the alliscode-github-synchronized-access branch from 1ffbaa1 to de8c4ea Compare October 29, 2026 00:23
@alliscode
alliscode requested an auto review from Copilot October 29, 2026 00:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

@alliscode
alliscode force-pushed the alliscode-github-synchronized-access branch from ab3d563 to a6e5b8d Compare October 29, 2026 11:48
@alliscode
alliscode requested an auto review from Copilot October 29, 2026 11:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alliscode
alliscode force-pushed the alliscode-github-synchronized-access branch from a6e5b8d to 125e8e8 Compare October 29, 2026 15:00
@alliscode
alliscode requested an auto review from Copilot October 29, 2026 15:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Ben Thomas and others added 11 commits October 29, 2026 09:43
Add opt-in GitHub-synchronized admission and prototype baselines while preserving explicit Hub overrides and bounded stale-access behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Serialize reconciliation claims with source generations and scope outage fallback to the repository whose live permission check failed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Serialize synchronized membership changes, reject stale admission writes, resolve repositories by immutable ID, and keep lower-precedence baselines isolated from explicit Hub decisions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Backfill compatibility memberships, persist negative confirmations, enforce synchronized session freshness, and align reconciliation, invitation, listing, and workspace-read behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Order live admission confirmations, revoke cached access on repository loss, preserve invitation authority during source outages, and harden webhook and installation lifecycle handling.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Require collaborator membership for public sources, separate per-user admission ordering from reconciliation generations, preserve outage fallback, and cover policy mutation APIs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Share per-user ordering across reconciliation and sign-in, preserve valid manual outcomes, batch removal enforcement, and audit synchronized administration preservation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Share per-user ordering across scans and sign-ins, filter enforcement candidates, retain partial confirmations, and log bounded scheduled failures.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Revalidate cached admission transactionally, order per-result confirmations, revoke without source credentials, bound reconciliation work, and expose prototype policy state.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refresh immutable logins, revoke installations safely, scope webhook mutations, coalesce retries, and audit batched reconciliation updates.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Preserve bounded legacy admission and provider validation while adapting synchronized access to the rewritten credential and query boundaries.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@alliscode
alliscode force-pushed the alliscode-github-synchronized-access branch from 125e8e8 to 0bcb5b9 Compare October 29, 2026 16:49

@nshki nshki left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my review for #147, if you could run some self-review rounds with your agent using our repo conventions, that would be great. There are similar violations to #147 in this layer.

Assert the eventual follow-up source and state instead of freezing request counts that vary with concurrent batch completion.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

3 participants