Skip to content

Make the PLC directory URL configurable - #168

Merged
haileyok merged 2 commits into
mainfrom
hailey/configurable-plc-url
Sep 26, 2026
Merged

haileyok merged 2 commits into
mainfrom
hailey/configurable-plc-url

Conversation

@haileyok

@haileyok haileyok commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Make the PLC directory configurable via --plc-url / COCOON_PLC_URL (default https://plc.directory), so cocoon can run against a local PLC instance for integration testing without registering accounts in the real directory.
  • Closes Can the PLC directory URL be made configurable? #158.

Changes

  • Config: new --plc-url flag / COCOON_PLC_URL env var and server.Args.PlcURL. The value is validated in server.New (http/https scheme, host required, no query/fragment, trailing slash trimmed; empty → default). A warning is logged when a non-default directory is in use.
  • PLC client: plc.Client now uses the configured URL for DID creation, operation submission, /data, and /log/audit.
  • DID resolution: identity.Passport takes an optional WithPlcURL(...) option and resolves did:plc documents against it. NewPassport(h, bc) remains source-compatible.
  • OAuth permission sets: new scopes.NewIndigoResolverWithPLCURL, which uses indigo's default directory config with PLCURL overridden.
  • identity package API change: DidToDocUrl, FetchDidDoc, FetchDidData, FetchDidAuditLog, and ResolveService now take an explicit plcURL argument (empty → default). Adds identity.DefaultPlcURL and identity.NormalizePlcURL.
  • FetchDidAuditLog now uses the passed-in HTTP client rather than http.DefaultClient.
  • The default URL is defined once, in identity.DefaultPlcURL. The flag default and the plc.NewClient fallback both reference it.
  • README section and docker-compose passthrough for COCOON_PLC_URL. It is empty by default and resolves to identity.DefaultPlcURL.

Validation

  • CGO_ENABLED=1 go test -race ./...: all packages pass.
  • go build ./..., go vet ./..., and gofmt -l . are clean.
  • New tests:
    • identity/identity_test.go: URL normalization, DidToDocUrl, the fetch helpers, and Passport against a fake PLC httptest server.
    • oauth/scopes/resolver_test.go: the resolver's PLCURL override and its default.
  • Not run: an end-to-end run against a real local PLC instance.

Review notes

  • The identity helper signature changes are breaking for anyone importing github.com/haileyok/cocoon/identity as a library. All in-repo callers are updated.
  • NewIndigoResolverWithPLCURL type-asserts indigo's DefaultDirectory() internals (*CacheDirectory → *BaseDirectory). The unit test fails if an indigo bump changes that shape.
  • Handle resolution (DNS / .well-known) and did:web are unaffected.

Add --plc-url / COCOON_PLC_URL (default https://plc.directory) and thread it
through the PLC client, the Passport DID resolver, and the OAuth permission-set
resolver, so cocoon can run against a local PLC directory for testing.

Closes #158
Use identity.DefaultPlcURL for the --plc-url flag default and the plc.Client
fallback, and drop the hardcoded default from the docker-compose files (an empty
value resolves to the same constant).
@haileyok
haileyok marked this pull request as ready for review September 26, 2026 20:15
@haileyok
haileyok merged commit 677baa4 into main Sep 26, 2026
1 check passed
@haileyok
haileyok deleted the hailey/configurable-plc-url branch September 28, 2026 23: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.

Can the PLC directory URL be made configurable?

1 participant