Loading
Commits on Source 2
-
Matt Cockayne authored
Spec 0008 D5, rung 1 of the ladder in D10. NewProviderFromClient takes a *gitlab.Client the caller already holds and builds a provider on it. The rung TRANSFERS THE CREDENTIAL OBLIGATION, exactly as WithHTTPClient (D4) transfers the redirect-policy obligation. Settings.Credential must be nil and Settings.APIURL must be empty; both are refused rather than silently ignored, because a field that quietly does nothing is worse than one that says no. The API base comes from the client, which is what will make the requests. ASSET DOWNLOADS ARE ANONYMOUS AT THIS RUNG, and the documentation says so at the constructor rather than leaving it to be discovered. A GitLab release asset is a LINK — an arbitrary URL a release author supplied — so fetching it is not an API call and go-gitlab never makes it. This provider fetches it directly and would normally attach PRIVATE-TOKEN itself. It cannot do that with an injected client, and the spike behind spec 0008's D5 revision is why. Every method on go-gitlab's Client was enumerated at v2.58.0: BaseURL, Do, HTTPClient, NewRequest, NewRequestToURL and UploadRequest, with UserAgent, GraphQL and the service interfaces as the only exported fields. Nothing yields the token or the AuthSource, and HTTPClient returns a client with no credential attached — proven by request, not by reading. The one method that would work is NewRequestToURL, and it must not be used: it attaches the credential to an arbitrary URL, refuses an off-instance target when the request is BUILT, and then follows a redirect off-host still carrying the token. An instance asset link redirecting to object storage is GitLab's ordinary path for a large file, so that is a leak on the common case rather than an exotic one. So a public asset downloads and a private one does not, which is a documented property of the rung. A caller who needs authenticated downloads uses a lower one — a transport, or Settings with a Credential — where this module still owns both the credential and the redirect policy that keeps it on the pinned host. Every guard is falsified against the mutant that removes it, including the anonymous-download property: inventing a token fails TestFromClientDownloadsAnonymously.
-
Matt Cockayne authored