docker/docker-credential-helpers

GitHub: docker/docker-credential-helpers

一组将 Docker 登录凭证安全存储到操作系统原生密钥库的辅助程序。

Stars: 1304 | Forks: 196

[![GitHub release](https://img.shields.io/github/release/docker/docker-credential-helpers.svg?style=flat-square)](https://github.com/docker/docker-credential-helpers/releases/latest) [![PkgGoDev](https://img.shields.io/badge/go.dev-docs-007d9c?style=flat-square&logo=go&logoColor=white)](https://pkg.go.dev/github.com/docker/docker-credential-helpers) [![Build Status](https://img.shields.io/github/actions/workflow/status/docker/docker-credential-helpers/build.yml?label=build&logo=github&style=flat-square)](https://github.com/docker/docker-credential-helpers/actions?query=workflow%3Abuild) [![Codecov](https://img.shields.io/codecov/c/github/docker/docker-credential-helpers?logo=codecov&style=flat-square)](https://codecov.io/gh/docker/docker-credential-helpers) [![Go Report Card](https://goreportcard.com/badge/github.com/docker/docker-credential-helpers?style=flat-square)](https://goreportcard.com/report/github.com/docker/docker-credential-helpers) ## 介绍 docker-credential-helpers 是一组程序,旨在利用原生存储来保证 Docker 凭证的安全。 ## 安装说明 前往 [Releases](https://github.com/docker/docker-credential-helpers/releases) 页面,并下载最适合您的二进制文件。将该二进制文件放入您的 `$PATH` 中,以便 Docker 能够找到它。 ## 构建 您可以使用 Docker 构建 credential helper: ``` # 安装 emulators $ docker run --privileged --rm tonistiigi/binfmt --install all # 创建 builder $ docker buildx create --use # 从远程 repository 构建 credential helpers 并输出到 ./bin/build $ docker buildx bake "https://github.com/docker/docker-credential-helpers.git" # 或从本地 source $ git clone https://github.com/docker/docker-credential-helpers.git $ cd docker-credential-helpers $ docker buildx bake ``` 或者,如果您的机器上已经安装了工具链: 1. 下载源码。 ``` $ git clone https://github.com/docker/docker-credential-helpers.git $ cd docker-credential-helpers ``` 2. 使用 `make` 构建您想要的程序。这将在仓库内的 `bin` 目录中生成一个可执行文件。 ``` $ make osxkeychain ``` 3. 将该二进制文件放入您的 `$PATH` 中,以便 Docker 能够找到它。 ``` $ cp bin/build/docker-credential-osxkeychain /usr/local/bin/ ``` ## 用法 ### 结合 Docker Engine 使用 在您的 `~/.docker/config.json` 文件中设置 `credsStore` 选项,其值为您想要使用的程序的后缀。例如,如果您想使用 `docker-credential-osxkeychain`,则将其设置为 `osxkeychain`。 ``` { "credsStore": "osxkeychain" } ``` ### 结合其他命令行应用程序使用 子包 [client](https://godoc.org/github.com/docker/docker-credential-helpers/client) 包含 了一些可供您在自己的命令行应用程序中调用外部程序的函数。 如果您需要与 helper 进行交互,需要了解三件事: 1. 要执行的程序名称,例如 `docker-credential-osxkeychain`。 2. 用于标识凭证的服务器地址,例如 `https://example.com`。 3. 当您想要存储凭证时,需要存储的用户名和密钥(secret)。 您可以在 [client](https://godoc.org/github.com/docker/docker-credential-helpers/client) 文档中查看每个函数的示例。 ### 可用程序 1. osxkeychain:提供了一个使用 OS X keychain 作为凭证存储的 helper。 2. secretservice:提供了一个使用 D-Bus secret service 作为凭证存储的 helper。 3. wincred:提供了一个使用 Windows credentials manager 作为存储的 helper。 4. pass:提供了一个使用 `pass` 作为凭证存储的 helper。 #### 注意事项 `pass` 需要进行配置,`docker-credential-pass` 才能正常工作。 它必须使用 `gpg2` 密钥 ID 进行初始化。请确保您的 GPG 密钥存在于 `gpg2` 密钥环中,因为 `pass` 使用的是 `gpg2` 而不是常规的 `gpg`。 ## 开发 credential helper 可以是任何能够从标准输入读取值的程序。我们使用命令行中的第一个参数来区分要执行的命令类型。有四个有效值: - `store`:将凭证添加到 keychain。标准输入中的 payload 是一个包含 `ServerURL`、`Username` 和 `Secret` 的 JSON 文档。 - `get`:从 keychain 检索凭证。标准输入中的 payload 是 `ServerURL` 的原始值。 - `erase`:从 keychain 移除凭证。标准输入中的 payload 是 `ServerURL` 的原始值。 - `list`:列出已存储的凭证。没有标准输入 payload。 该仓库还包含了用于以 Go 语言实现新凭证程序的库。添加一个新的 helper 程序非常简单。您可以在 [osxkeychain](osxkeychain) 目录中了解 OS X keychain helper 的工作原理。 1. 在 `YOUR_PACKAGE/` 中实现 `credentials.Helper` 接口 2. 在 `YOUR_PACKAGE/cmd/` 中创建一个主程序。 3. 添加 make 任务以构建您的程序并运行测试。 ## 许可证 MIT。查看 [LICENSE](LICENSE) 获取更多信息。
标签:Docker, EVTX分析, Golang, SOC Prime, 代码分析, 凭证管理, 安全编程, 安全防御评估, 开发工具, 日志审计, 系统钥匙串, 请求拦截