Skip to content

feat(gitlab): Dynamic Client Registration (DCR) for self-hosted instances#123

Closed
jaysomani wants to merge 3 commits into
utopia-php:mainfrom
jaysomani:feat/gitlab-dcr-support
Closed

feat(gitlab): Dynamic Client Registration (DCR) for self-hosted instances#123
jaysomani wants to merge 3 commits into
utopia-php:mainfrom
jaysomani:feat/gitlab-dcr-support

Conversation

@jaysomani

Copy link
Copy Markdown
Contributor

Adds DCR support (RFC 7591) for self-hosted GitLab 18.6+ instances.

New methods on the GitLab VCS adapter:

  • registerDynamicClient(string $endpoint, string $redirectUri): array — registers Appwrite as a public PKCE OAuth client via POST /oauth/register, returns client_id (no secret)
  • discoverDcrEndpoint(string $endpoint): ?string — checks /.well-known/oauth-authorization-server/api/v4/mcp for DCR availability, returns null if unsupported

Key implementation details:

  • token_endpoint_auth_method: none (public/PKCE client)
  • Throws if GitLab unexpectedly returns client_secret (signals confidential client mismatch)
  • Strict redirect_uri match validation on response
  • Explicit handling for 404 (old GitLab), 403 (DCR disabled), 429 (rate limited)
  • 16 unit tests + E2E tests against real GitLab 18.10

Reference: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/197644

jaysomani and others added 3 commits July 23, 2026 16:06
…hosted instances

Adds registerDynamicClient() and discoverDcrEndpoint() to the GitLab VCS adapter.
DCR (RFC 7591) allows Appwrite to auto-register as an OAuth client on self-hosted
GitLab instances (18.6+) without requiring manual admin setup.

- registerDynamicClient(): POSTs to /oauth/register, returns public PKCE client_id
- discoverDcrEndpoint(): checks /.well-known/oauth-authorization-server/api/v4/mcp
- Handles all failure cases explicitly (404=old GitLab, 403=disabled, 429=rate limit)
- Adds callDcr(), an overridable protected helper for calls outside /api/v4, so
  unit tests can stub GitLab responses without a real instance or mocking library
- Unit tests for all success/failure paths (16 tests, no network dependency)
- E2E tests against the docker-compose GitLab 18.10 instance

GitLab DCR reference: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/197644

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…hosted instances

Adds registerDynamicClient() and discoverDcrEndpoint() to the GitLab VCS adapter.
DCR (RFC 7591) allows Appwrite to auto-register as an OAuth client on self-hosted
GitLab instances (18.6+) without requiring manual admin setup.

- registerDynamicClient(): POSTs to /oauth/register, returns public PKCE client_id
- discoverDcrEndpoint(): checks /.well-known/oauth-authorization-server/api/v4/mcp
- Handles all failure cases explicitly (404=old GitLab, 403=disabled, 429=rate limit)
- Adds callDcr(), an overridable protected helper for calls outside /api/v4, so
  unit tests can stub GitLab responses without a real instance or mocking library
- Unit tests for all success/failure paths (16 tests, no network dependency)
- E2E tests against the docker-compose GitLab 18.10 instance

GitLab DCR reference: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/197644

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@jaysomani jaysomani closed this Jul 23, 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