Spring 云配置服务器 - 连接到 github 的用户 ID 和密码
Spring Cloud Config Server - User id and Password to connect to github
我查看了 github 存储库中许多 spring 云配置服务器的代码,下面是作为 属性 文件的一部分提供的 2 个值。我相信为了连接到 github 的 https 端点,用户名和密码也是必需的。这些可能是环境变量的一部分吗?
server.port=7070
spring.cloud.config.server.git.uri=https://
编辑:
下面是我在spring网站上看到的例子。但是,在我企业内的所有 github 回购中,我没有看到设置用户 ID 和密码,因为它们是敏感信息。如果 属性 文件中未提供 uid / pwd,如何设置或配置服务器访问 github url?
spring:
cloud:
config:
server:
git:
uri: https://github.com/spring-cloud-samples/config-repo
username: trolley
password: strongpassword
- for public repository 不需要使用 username 和 password 或其他获取配置属性的授权,对于 private repository auth 是必需的。
- 可以从os或java-系统-属性和命令行的环境中设置变量os。对于优先级:command-line-param > java-system-属性 > os-env > application.properties。
所以,例如,如果我设置 属性 直接使用命令行(具有最高优先级)会怎么样:
java -jar config-server.jar --spring.cloud.config.server.git.username=xxx --spring.cloud.config.server.git.password=xxx
其中包含 CI 工具中的所有参数或随后由某人管理的任何内容,您不会在源代码中看到它。
简单提示 -
转到github.com -> 开发人员设置 -> 创建访问令牌,然后创建一个仅具有读取回购权限的访问令牌。这样就可以在不提供纯文本密码的情况下公开私有存储库!
像这样 -
spring.cloud.config.server.git.password=0371abshak3048sa8d81828488483sd302
是的,只需使用这样的变量:
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}
并在任何 CI 上设置这些环境变量。
例如作为 GitHub 操作的秘密:
- name: Build config-service
env:
GIT_REPO_URL: ${{ secrets.GIT_REPO_URL }}
GIT_USERNAME: ${{ secrets.GIT_USERNAME }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
而且您似乎不能再使用密码访问 GitHub,您需要在此处通过 GitHub 令牌 spring.cloud.config.server.git.password
我查看了 github 存储库中许多 spring 云配置服务器的代码,下面是作为 属性 文件的一部分提供的 2 个值。我相信为了连接到 github 的 https 端点,用户名和密码也是必需的。这些可能是环境变量的一部分吗?
server.port=7070
spring.cloud.config.server.git.uri=https://
编辑:
下面是我在spring网站上看到的例子。但是,在我企业内的所有 github 回购中,我没有看到设置用户 ID 和密码,因为它们是敏感信息。如果 属性 文件中未提供 uid / pwd,如何设置或配置服务器访问 github url?
spring:
cloud:
config:
server:
git:
uri: https://github.com/spring-cloud-samples/config-repo
username: trolley
password: strongpassword
- for public repository 不需要使用 username 和 password 或其他获取配置属性的授权,对于 private repository auth 是必需的。
- 可以从os或java-系统-属性和命令行的环境中设置变量os。对于优先级:command-line-param > java-system-属性 > os-env > application.properties。
所以,例如,如果我设置 属性 直接使用命令行(具有最高优先级)会怎么样:
java -jar config-server.jar --spring.cloud.config.server.git.username=xxx --spring.cloud.config.server.git.password=xxx
其中包含 CI 工具中的所有参数或随后由某人管理的任何内容,您不会在源代码中看到它。
简单提示 -
转到github.com -> 开发人员设置 -> 创建访问令牌,然后创建一个仅具有读取回购权限的访问令牌。这样就可以在不提供纯文本密码的情况下公开私有存储库!
像这样 -
spring.cloud.config.server.git.password=0371abshak3048sa8d81828488483sd302
是的,只需使用这样的变量:
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}
并在任何 CI 上设置这些环境变量。 例如作为 GitHub 操作的秘密:
- name: Build config-service
env:
GIT_REPO_URL: ${{ secrets.GIT_REPO_URL }}
GIT_USERNAME: ${{ secrets.GIT_USERNAME }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
而且您似乎不能再使用密码访问 GitHub,您需要在此处通过 GitHub 令牌 spring.cloud.config.server.git.password