diff --git a/CHANGELOG.md b/CHANGELOG.md index 54aa73e540b..a1390d68d4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ All notable changes to Sourcegraph are documented in this file. ### Removed - indexed-search has removed the deprecated environment variable ZOEKT_ENABLE_LAZY_DOC_SECTIONS [zoekt#620](https://github.com/sourcegraph/zoekt/pull/620) +- The federation feature that could redirect users from their own Sourcegraph instance to public repositories on Sourcegraph.com has been removed. [#55161](https://github.com/sourcegraph/sourcegraph/pull/55161) ## 5.1.4 diff --git a/cmd/frontend/backend/BUILD.bazel b/cmd/frontend/backend/BUILD.bazel index 61907c2a445..d685f5f3f82 100644 --- a/cmd/frontend/backend/BUILD.bazel +++ b/cmd/frontend/backend/BUILD.bazel @@ -32,7 +32,6 @@ go_library( "//internal/authz", "//internal/authz/permssync", "//internal/conf", - "//internal/conf/deploy", "//internal/database", "//internal/database/dbcache", "//internal/encryption/keyring", diff --git a/cmd/frontend/backend/repos.go b/cmd/frontend/backend/repos.go index 7fc72192c18..ad0f69a55eb 100644 --- a/cmd/frontend/backend/repos.go +++ b/cmd/frontend/backend/repos.go @@ -3,7 +3,6 @@ package backend import ( "context" "fmt" - "net/url" "time" "github.com/prometheus/client_golang/prometheus" @@ -15,8 +14,6 @@ import ( "github.com/sourcegraph/sourcegraph/cmd/frontend/envvar" "github.com/sourcegraph/sourcegraph/internal/api" "github.com/sourcegraph/sourcegraph/internal/authz" - "github.com/sourcegraph/sourcegraph/internal/conf" - "github.com/sourcegraph/sourcegraph/internal/conf/deploy" "github.com/sourcegraph/sourcegraph/internal/database" "github.com/sourcegraph/sourcegraph/internal/database/dbcache" "github.com/sourcegraph/sourcegraph/internal/errcode" @@ -105,25 +102,12 @@ func (s *repos) GetByName(ctx context.Context, name api.RepoName) (_ *types.Repo } newName, err := s.add(ctx, name) - if err == nil { - return s.store.GetByName(ctx, newName) + if err != nil { + return nil, err } - if errcode.IsNotFound(err) && shouldRedirect(name) { - return nil, ErrRepoSeeOther{RedirectURL: (&url.URL{ - Scheme: "https", - Host: "sourcegraph.com", - Path: string(name), - RawQuery: url.Values{"utm_source": []string{deploy.Type()}}.Encode(), - }).String()} - } + return s.store.GetByName(ctx, newName) - return nil, err -} - -func shouldRedirect(name api.RepoName) bool { - return !conf.Get().DisablePublicRepoRedirects && - extsvc.CodeHostOf(name, extsvc.PublicCodeHosts...) != nil } var metricIsRepoCloneable = promauto.NewCounterVec(prometheus.CounterOpts{ diff --git a/cmd/frontend/graphqlbackend/schema.graphql b/cmd/frontend/graphqlbackend/schema.graphql index 29afa705e26..b1dc9a135da 100755 --- a/cmd/frontend/graphqlbackend/schema.graphql +++ b/cmd/frontend/graphqlbackend/schema.graphql @@ -1365,10 +1365,10 @@ type Query { uri: String ): Repository """ - Looks up a repository by either name or cloneURL or hashedName. When the repository does not exist on the server - and "disablePublicRepoRedirects" is "false" in the site configuration, it returns a Redirect to - an external Sourcegraph URL that may have this repository instead. Otherwise, this query returns - null. + Looks up a repository by either name or cloneURL or hashedName. When the + repository does not exist on the server, it returns a Redirect to an + external Sourcegraph URL that may have this repository instead. Otherwise, + this query returns null. """ repositoryRedirect( """ diff --git a/dev/site-config.json b/dev/site-config.json index b0f36975550..51f071e5ec1 100644 --- a/dev/site-config.json +++ b/dev/site-config.json @@ -9,6 +9,5 @@ "externalURL": "http://localhost:3080/", "update.channel": "release", "experimentalFeatures": {}, - "disablePublicRepoRedirects": true, "repoListUpdateInterval": 1 } diff --git a/doc/admin/config/site_config.md b/doc/admin/config/site_config.md index 89d31a49f83..a54f6e384b6 100644 --- a/doc/admin/config/site_config.md +++ b/doc/admin/config/site_config.md @@ -29,7 +29,6 @@ auth.sessionExpiry git.cloneURLToRepositoryName searchScopes extensions -disablePublicRepoRedirects ``` ## Editing your site configuration if you cannot access the web UI diff --git a/doc/admin/federation/index.md b/doc/admin/federation/index.md deleted file mode 100644 index 288bb6459c8..00000000000 --- a/doc/admin/federation/index.md +++ /dev/null @@ -1,9 +0,0 @@ -# Federation - -Federation refers to using multiple Sourcegraph servers together, each of which is responsible for a subset of repositories. - -Currently the only supported federation use case is [redirecting your Sourcegraph instance's users to Sourcegraph.com for _public_ repositories](public_repositories.md) (instead of mirroring, analyzing, and indexing public repositories on your Sourcegraph instance). - -## Future plans - -We plan to enhance federation in the future to support merging data (such as cross-references) from multiple Sourcegraph instances, sharing user accounts, etc. [Post an issue](https://github.com/sourcegraph/sourcegraph/issues) if you have a specific feature request for federation. diff --git a/doc/admin/federation/public_repositories.md b/doc/admin/federation/public_repositories.md deleted file mode 100644 index 5542151a2fa..00000000000 --- a/doc/admin/federation/public_repositories.md +++ /dev/null @@ -1,20 +0,0 @@ -# Federation: redirecting to Sourcegraph.com for public repositories - -Sourcegraph instances can be configured to redirect users to [Sourcegraph.com](https://sourcegraph.com) for public repositories. This offloads the work of mirroring, analyzing, and indexing public repositories from your Sourcegraph instance. - -Example: If federation is enabled, a user on your Sourcegraph instance who tries to access a public repository at `https://sourcegraph.example.com/github.com/my/publicrepo` will be redirected to the same repository on Sourcegraph.com `https://sourcegraph.com/github.com/my/publicrepo`. - -Regardless of whether federation is enabled, private repositories are always handled entirely by your own Sourcegraph instance. - -### Benefits - -Enabling federation has the following benefits: - -- It offloads the work of mirroring, analyzing, and indexing public code to Sourcegraph.com, so your own instance's performance and resource consumption are unaffected. -- Users get full code navigation for all supported languages on Sourcegraph.com, even if your instance only has code navigation enabled for a subset of languages. -- Sourcegraph.com will show users more cross-repository references to code (via the "Find references" feature) than your instance because Sourcegraph.com's index is already very large. Building a comparable index of public code on your instance would require a lot of time and resources. -- It eliminates the risk of cloning and building public, untrusted code on your own instance (which may be running inside your private network). Sourcegraph.com applies strict isolation and resource quotas to mitigate this risk on our own infrastructure. - -### Configuration - -The `disablePublicRepoRedirects` [site configuration](../config/site_config.md) option disables redirection. diff --git a/doc/admin/index.md b/doc/admin/index.md index fac28ba639b..f2f7b5ca723 100644 --- a/doc/admin/index.md +++ b/doc/admin/index.md @@ -65,7 +65,6 @@ For deployment configuration, please refer to the relevant [installation guide]( - [Batch Changes](../batch_changes/index.md) - [Beta and experimental features](beta_and_experimental_features.md) - [Code navigation](../code_navigation/index.md) -- [Federation](federation/index.md) - [Pings](pings.md) - [Pricing and subscriptions](subscriptions/index.md) - [Search](search.md) diff --git a/internal/conf/confdefaults/confdefaults.go b/internal/conf/confdefaults/confdefaults.go index 1e94cece3cb..3cd9fe37a6e 100644 --- a/internal/conf/confdefaults/confdefaults.go +++ b/internal/conf/confdefaults/confdefaults.go @@ -45,9 +45,7 @@ var DockerContainer = conftypes.RawUnified{ "type": "builtin", "allowSignup": true } - ], - - "disablePublicRepoRedirects": true, + ] }`, } @@ -89,7 +87,7 @@ var App = conftypes.RawUnified{ "codeIntelAutoIndexing.enabled": true, "codeIntelAutoIndexing.allowGlobalPolicies": true, "executors.frontendURL": "http://host.docker.internal:3080", - "experimentalFeatures": { + "experimentalFeatures": { "structuralSearch": "disabled" }, "cody.enabled": true, @@ -100,7 +98,7 @@ var App = conftypes.RawUnified{ }, "embeddings": { "enabled": true, - "provider": "sourcegraph" + "provider": "sourcegraph" } }`, } diff --git a/internal/conf/parse.go b/internal/conf/parse.go index b7604336716..0df3e8e3262 100644 --- a/internal/conf/parse.go +++ b/internal/conf/parse.go @@ -46,7 +46,6 @@ var requireRestart = []string{ "git.cloneURLToRepositoryName", "searchScopes", "extensions", - "disablePublicRepoRedirects", "auth.userOrgMap", "auth.providers", "externalURL", diff --git a/internal/conf/validate_test.go b/internal/conf/validate_test.go index 5fa7920eb85..4c8e066d4c9 100644 --- a/internal/conf/validate_test.go +++ b/internal/conf/validate_test.go @@ -517,7 +517,6 @@ func getTestSiteWithSecrets(testSecrets testSecrets, optionalEdit ...string) str email = optionalEdit[0] } return fmt.Sprintf(`{ - "disablePublicRepoRedirects": true, "repoListUpdateInterval": 1, "email.address": "%s", "executors.accessToken": "%s", diff --git a/schema/schema.go b/schema/schema.go index a88d99b8162..f768d1bb277 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -2494,7 +2494,7 @@ type SiteConfiguration struct { DisableFeedbackSurvey bool `json:"disableFeedbackSurvey,omitempty"` // DisableNonCriticalTelemetry description: DEPRECATED. Has no effect. DisableNonCriticalTelemetry bool `json:"disableNonCriticalTelemetry,omitempty"` - // DisablePublicRepoRedirects description: Disable redirects to sourcegraph.com when visiting public repositories that can't exist on this server. + // DisablePublicRepoRedirects description: DEPRECATED! Disable redirects to sourcegraph.com when visiting public repositories that can't exist on this server. DisablePublicRepoRedirects bool `json:"disablePublicRepoRedirects,omitempty"` // Dotcom description: Configuration options for Sourcegraph.com only. Dotcom *Dotcom `json:"dotcom,omitempty"` diff --git a/schema/site.schema.json b/schema/site.schema.json index eb5e9e4ad89..37bb1531bcb 100644 --- a/schema/site.schema.json +++ b/schema/site.schema.json @@ -804,10 +804,11 @@ ] }, "disablePublicRepoRedirects": { - "description": "Disable redirects to sourcegraph.com when visiting public repositories that can't exist on this server.", + "description": "DEPRECATED! Disable redirects to sourcegraph.com when visiting public repositories that can't exist on this server.", "type": "boolean", "group": "External services", - "examples": [true] + "examples": [true], + "deprecationMessage": "Deprecated because it's no longer supported and hasn't been working for a while." }, "git.cloneURLToRepositoryName": { "description": "JSON array of configuration that maps from Git clone URL to repository name. Sourcegraph automatically resolves remote clone URLs to their proper code host. However, there may be non-remote clone URLs (e.g., in submodule declarations) that Sourcegraph cannot automatically map to a code host. In this case, use this field to specify the mapping. The mappings are tried in the order they are specified and take precedence over automatic mappings.",