Skip to content

feat: reject duplicate service registrations #102

Closed

Description

@uniqueg

Why?

The only uniqueness constraint on registered services is the unique index on id, and POST /services generates a new random id on every call. The same deployment can therefore be registered any number of times, by the same or by different users. With ownership (#62), every copy has its own owner. This confuses users of the registry and breaks consumers that use it as a list of backends (e.g., elixir-cloud-aai/protes#202 would see the same TES twice).

How?

A service is identified by its base URL (url: "the URL to which all endpoints should be relative") and its API type:

  1. Key: normalized url plus type.group and type.artifact (case-insensitive). Not type.version: upgrading a service to a new API version updates its entry. The API type covers the rare case of several APIs under the same base URL.
  2. URL normalization: lowercase scheme and host, remove the default port (443 for https, 80 for http), the trailing slash, query and fragment. Reject URLs with user info (user:password@).
  3. Storage: an internal field with the key, computed on every write (POST, PUT) and excluded from responses (like _id), with a unique index in config.yaml.
  4. Conflicts: POST /services, or a PUT that changes the URL or type to a key that exists for another service, returns 409 Conflict. The problem details name the id of the existing service, so that the user can contact its owner or an admin.
  5. Existing data: if a deployment keeps data from before this change, creating the index fails while duplicates exist. Document how to find them (e.g., an aggregation on the normalized key) and resolve them before upgrading.
  6. Documentation: README and API description, including the squatting risk below.
  7. Tests: spelling variants of the same URL (case, default port, trailing slash) conflict; different types under the same URL and different URLs don't; PUT of a service onto another service's key conflicts; PUT of a service with unchanged key succeeds.

Squatting risk (to document): anyone logged in can register a URL first, including a URL of a deployment they don't operate, and thereby block its real operator, who would get 409. The squatter would own that entry. Mitigations: admins can delete such entries or reassign their owners (#62); the admin-set "verified" flag (#64) lets consumers rely only on entries checked by admins. Proving control of the URL (e.g., by fetching {url}/service-info at registration) was considered and rejected: the service-info id is self-declared, and fetching user-supplied URLs from the registry would allow server-side request forgery.

Acceptance criteria

  • The same service (same normalized URL and API type) cannot be registered twice; the response is 409 and names the existing entry.
  • Spelling variants of a URL are detected as the same service.
  • The squatting risk and how admins handle it are documented.

Dependencies: #62 (ownership, admins). Related: #64 (verified flag), elixir-cloud-aai/generic-issues#29 (registrations by operators). The UI should show the conflict message (tracked in cloud-registry-ui).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions