-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Hide information in campaigns based on repository permissions #11071
Conversation
2f71412 to
f369569
Compare
Codecov Report
@@ Coverage Diff @@
## master #11071 +/- ##
==========================================
+ Coverage 46.45% 46.54% +0.09%
==========================================
Files 1368 1373 +5
Lines 77325 77508 +183
Branches 6627 6582 -45
==========================================
+ Hits 35919 36074 +155
- Misses 37982 38004 +22
- Partials 3424 3430 +6
|
|
"Changeset/patch in a private repository" is a fine label for now. I will think of what it should be (and how it should look), and that doesn't need to block this PR. 👍 |
7d9ee62 to
6042fa5
Compare
|
@LawnGnome @ryanslade Along with @eseliger's review, would be great if one of you could also take a look at this :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'm a bit confused about the various changeset resolvers. Maybe it's worth adding some comments where they're defined?
We have ChangesetResolver and HiddenExternalChangesetResolver and ExternalChangesetResolver that all appear to contain the same interface:
type CommonInterface interface {
ID() graphql.ID
CreatedAt() DateTime
UpdatedAt() DateTime
NextSyncAt() *DateTime
State() campaigns.ChangesetState
Campaigns(ctx context.Context, args *ListCampaignArgs) (CampaignsConnectionResolver, error)
ToExternalChangeset() (ExternalChangesetResolver, bool)
ToHiddenExternalChangeset() (HiddenExternalChangesetResolver, bool)
}I wonder if embedding that interface in all three would make that clearer?
Ah, I see what you mean. Yeah, I'll try that. Although I have to say that some part of the confusion seems to me to be "unsolvable" since we have to match GraphQL interfaces/types, but can't use the same "types" as in GraphQL (if GraphQL schema says "interface" we can't necessarily use a Go interface for that, etc.) |
This version includes the fix in sourcegraph/src-cli#213 which is required for https://github.com/sourcegraph/sourcegraph/pull/11071.
This version includes the fix in sourcegraph/src-cli#213 which is required for https://github.com/sourcegraph/sourcegraph/pull/11071.
This implements part 1/2 of https://github.com/sourcegraph/sourcegraph/issues/10809 by incorporating repository permission in the read-path of the campaigns resolvers and hiding information from users that don't have access to associated repositories.
The PR also depends on sourcegraph/src-cli#213, which will be merged and released after this PR in a src-cli minor version release. After that release I'll bump the min-required src-cli in sourcegraph.
What this PR does, in concrete terms:
PatchandExternalChangesettypes in the GraphQL schema intoPatch/HiddenPatchandExternalChangeset/HiddenExternalChangeset. The types should implement the same interface but the "hidden" variants hide most information besides their own ID and the campaign they're associated with.ChangesetsConnectionreturn aHiddenExternalChangesetwhen the user doesn't have access to the underlying repository.PatchesConnectionreturn aHiddenPatchwhen the user doesn't have access to the underlying repository.ChangesetByID,PatchByIDreturn a hidden changeset/patch if the user doesn't have access to the repository. Note: This is a slight variation from the original task in the ticket, since we don't return a 404, but I think this makes far more sense, since we expose the "hidden" types with IDs.Campaign.status.errorsfilter out the errors if the user doesn't have access to the underlying repositories.Campaign.diffStatdo not include stats for patches/changesets the user doesn't have access to.PatchSet.diffStatdo not include stats for patches the user doesn't have access to.In a follow-up PR I'm going to incorporate repository permissions into the mutations of the API.
Note: Merging is safe, since permission levels are already in place and we still have the admin check around campaigns.
Screenshots