[英]Spring Cloud Config Server - User id and Password to connect to github
I looked at the code for a number of spring cloud config servers in github repo and below are the 2 values that are provided as part of property file.我查看了 github 存储库中许多 spring 云配置服务器的代码,下面是作为属性文件的一部分提供的 2 个值。 I believe in order to connect to https end point of github , user id and password are also necessary.我相信为了连接到 github 的 https 端点,用户 ID 和密码也是必要的。 Could these perhaps be part of environment variables?这些可能是环境变量的一部分吗?
server.port=7070
spring.cloud.config.server.git.uri=https://
EDIT:编辑:
Below is the example that I saw in spring website.下面是我在 spring 网站上看到的示例。 However in all the github repos within my enterprise I don't see userid and password being set as they are sensitive info.但是,在我企业内的所有 github 存储库中,我没有看到用户 ID 和密码被设置,因为它们是敏感信息。 How could it be set or config server access github url , if uid / pwd is not provided in the property file?如果属性文件中未提供 uid / pwd ,如何设置或配置服务器访问 github url ?
spring:
cloud:
config:
server:
git:
uri: https://github.com/spring-cloud-samples/config-repo
username: trolley
password: strongpassword
So, for example what if i set property use command-line directly (which has highest precedence.) like:因此,例如,如果我直接设置属性使用命令行(具有最高优先级),例如:
java -jar config-server.jar --spring.cloud.config.server.git.username=xxx --spring.cloud.config.server.git.password=xxx
which contain all param in CI tools or whatever then managed by someone, you wouldn't see that in source code.其中包含 CI 工具中的所有参数或由某人管理的任何内容,您不会在源代码中看到它。
Easy Tip -简单提示 -
Go to github.com -> Developer settings -> Create Access Token, then create an access token with a read repo priviliage only.转到 github.com -> 开发人员设置 -> 创建访问令牌,然后创建一个仅具有读取 repo 权限的访问令牌。 that way a private repository can be expose without giving plain text password!这样就可以在不提供纯文本密码的情况下公开私有存储库!
Something like this -像这样的东西——
spring.cloud.config.server.git.password=0371abshak3048sa8d81828488483sd302 spring.cloud.config.server.git.password=0371abshak3048sa8d81828488483sd302
Yes, just use variables like this:是的,只需使用这样的变量:
spring.cloud.config.server.git.uri=${GIT_REPO_URL}
spring.cloud.config.server.git.username=${GIT_USERNAME}
spring.cloud.config.server.git.password=${GIT_TOKEN}
And set those env vars on any CI.并在任何 CI 上设置这些环境变量。 For example as secrets on GitHub Actions:例如作为 GitHub Actions 上的秘密:
- name: Build config-service
env:
GIT_REPO_URL: ${{ secrets.GIT_REPO_URL }}
GIT_USERNAME: ${{ secrets.GIT_USERNAME }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
And seems like you can't use password anymore to access GitHub, you need top pass GitHub token here spring.cloud.config.server.git.password
并且似乎您不能再使用密码来访问 GitHub,您需要在此处顶部传递 GitHub 令牌spring.cloud.config.server.git.password
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.