diff --git a/wsmaster/che-core-api-auth-github/src/main/java/org/eclipse/che/security/oauth/GitHubOAuthAuthenticatorProvider.java b/wsmaster/che-core-api-auth-github/src/main/java/org/eclipse/che/security/oauth/GitHubOAuthAuthenticatorProvider.java index 4a101737ee..c975fdd219 100644 --- a/wsmaster/che-core-api-auth-github/src/main/java/org/eclipse/che/security/oauth/GitHubOAuthAuthenticatorProvider.java +++ b/wsmaster/che-core-api-auth-github/src/main/java/org/eclipse/che/security/oauth/GitHubOAuthAuthenticatorProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2021 Red Hat, Inc. + * Copyright (c) 2012-2022 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ @@ -70,8 +70,8 @@ public class GitHubOAuthAuthenticatorProvider implements Provider implements FileContentProvider { private final T remoteFactoryUrl; - private final URLFetcher urlFetcher; private final PersonalAccessTokenManager personalAccessTokenManager; private final GitCredentialManager gitCredentialManager; + protected final URLFetcher urlFetcher; public AuthorizingFileContentProvider( T remoteFactoryUrl, @@ -74,6 +75,11 @@ public class AuthorizingFileContentProvider "Failed to fetch a content from URL %s due to TLS key misconfiguration. Please refer to the docs about how to correctly import it. ", requestURL)); throw new DevfileException(exception.getMessage(), cause); + } else if (exception instanceof FileNotFoundException) { + if (isPublicRepository(remoteFactoryUrl)) { + // for public repo-s return 404 as-is + throw exception; + } } // unable to determine exact cause, so let's just try to authorize... try { @@ -109,6 +115,10 @@ public class AuthorizingFileContentProvider } } + protected boolean isPublicRepository(T remoteFactoryUrl) { + return false; + } + private String formatUrl(String fileURL) throws DevfileException { String requestURL; try {