从在GitHub上托管的Spring Cloud Config Server访问的repo的身份验证问题

问题描述 投票:2回答:2

我在GitHub上的repo中托管配置。如果我保持回购公众一切都很好,但如果我把它私有化我面对:

org.eclipse.jgit.errors.TransportException: 
 https://github.com/my-user/my-repo:
 Authentication is required but no CredentialsProvider has been registered

我用来定位回购的属性是

spring.cloud.config.server.git.uri=https://github.com/my-user/my-repo

我应该怎么做才能正确配置私人仓库,谢谢

spring github spring-boot spring-cloud spring-cloud-config
2个回答
9
投票

你需要添加

spring.cloud.config.server.git.username=your_github_username
spring.cloud.config.server.git.password=your_github_password

事情应该为你锻炼


1
投票

不建议将GitHub用户名和密码硬编码到application.yml中。您将面临泄露GitHub帐户并将配置存储库的访问权限打开给Web上的任何人的风险。

您可以通过添加以下配置使用ssh作为身份验证方法:

spring:
  cloud:
    config:
      server:
        git:
          uri: [email protected]:qianyanseu/EagleEye-config.git
          searchPaths: licensingservice,organizationservice
          private_key_file: ~/.ssh/github_rsa

由于GitHub已更新身份验证算法,如果您使用的是早期版本的spring cloud,则还需要将以下依赖项添加到pom.xml:

<dependency>
   <groupId>com.jcraft</groupId>
   <artifactId>jsch</artifactId>
   <version>0.1.53</version>
</dependency>
© www.soinside.com 2019 - 2024. All rights reserved.