mirror of
				https://github.com/scm-manager/scm-manager.git
				synced 2025-10-31 02:25:53 +01:00 
			
		
		
		
	Integrate Plugin Center myCloudogu Authentication (#1884)
Allows scm-manager instances to authenticate with the configured plugin center. If the default plugin center is used, a myCloudogu account is used for authentication which in turn enables downloading special myCloudogu plugins directly through the plugin administration page. Co-authored-by: Konstantin Schaper <konstantin.schaper@cloudogu.com> Co-authored-by: Matthias Thieroff <93515444+mthieroff@users.noreply.github.com> Co-authored-by: Philipp Ahrendt <philipp.ahrendt@cloudogu.com>
This commit is contained in:
		| @@ -29,6 +29,7 @@ import com.google.common.hash.Hashing; | ||||
| import com.google.common.hash.HashingInputStream; | ||||
| import sonia.scm.SCMContextProvider; | ||||
| import sonia.scm.net.ahc.AdvancedHttpClient; | ||||
| import sonia.scm.net.ahc.AdvancedHttpRequest; | ||||
|  | ||||
| import javax.inject.Inject; | ||||
| import java.io.IOException; | ||||
| @@ -40,18 +41,19 @@ import java.util.Optional; | ||||
|  | ||||
| import static sonia.scm.plugin.Tracing.SPAN_KIND; | ||||
|  | ||||
| @SuppressWarnings("UnstableApiUsage") | ||||
|   // guava hash is marked as unstable | ||||
| @SuppressWarnings("UnstableApiUsage") // guava hash is marked as unstable | ||||
| class PluginInstaller { | ||||
|  | ||||
|   private final SCMContextProvider scmContext; | ||||
|   private final AdvancedHttpClient client; | ||||
|   private final PluginCenterAuthenticator authenticator; | ||||
|   private final SmpDescriptorExtractor smpDescriptorExtractor; | ||||
|  | ||||
|   @Inject | ||||
|   public PluginInstaller(SCMContextProvider scmContext, AdvancedHttpClient client, SmpDescriptorExtractor smpDescriptorExtractor) { | ||||
|   public PluginInstaller(SCMContextProvider scmContext, AdvancedHttpClient client, PluginCenterAuthenticator authenticator, SmpDescriptorExtractor smpDescriptorExtractor) { | ||||
|     this.scmContext = scmContext; | ||||
|     this.client = client; | ||||
|     this.authenticator = authenticator; | ||||
|     this.smpDescriptorExtractor = smpDescriptorExtractor; | ||||
|   } | ||||
|  | ||||
| @@ -128,7 +130,11 @@ class PluginInstaller { | ||||
|   } | ||||
|  | ||||
|   private InputStream download(AvailablePlugin plugin) throws IOException { | ||||
|     return client.get(plugin.getDescriptor().getUrl()).spanKind(SPAN_KIND).request().contentAsStream(); | ||||
|     AdvancedHttpRequest request = client.get(plugin.getDescriptor().getUrl()).spanKind(SPAN_KIND); | ||||
|     if (authenticator.isAuthenticated()) { | ||||
|       request.bearerAuth(authenticator.fetchAccessToken()); | ||||
|     } | ||||
|     return request.request().contentAsStream(); | ||||
|   } | ||||
|  | ||||
|   private Path createFile(AvailablePlugin plugin) throws IOException { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user