Authentication issue with repo accessed from Spring Cloud Config Server hosted on GitHub

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 07:15:00

问题


I'm hosting a configuration in a repo on GitHub. If I keep the repo public all's good, but if I make it private I face:

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

the property I use to target the repo is

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

What should I do to configure this properly with the private repo, thanks


回答1:


you need to add the

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

and things should workout for you




回答2:


It's not recommended to hardcode GitHub username and password into application.yml. You'll be at risk of leaking GitHub account and open access of your config repository to anyone on the web.

You can use ssh as authentication method by adding the following configuration:

spring:
  cloud:
    config:
      server:
        git:
          uri: git@github.com:qianyanseu/EagleEye-config.git
          searchPaths: licensingservice,organizationservice
          private_key_file: ~/.ssh/github_rsa

As GitHub has updated authentication algorithm, if you're using earlier version of spring cloud, you'll also need to add the following dependency to pom.xml:

<dependency>
   <groupId>com.jcraft</groupId>
   <artifactId>jsch</artifactId>
   <version>0.1.53</version>
</dependency>


来源:https://stackoverflow.com/questions/39922594/authentication-issue-with-repo-accessed-from-spring-cloud-config-server-hosted-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!