ios - 如何在 GitHub 中保存或安全避免 Facebook 或 LinkedIn 等社交网络的 key

标签 ios facebook git github linkedin

出于安全的原因,一些教程建议不要将 key 保存在GitHub 中,他们将文件保存在.gitignore 中,但是例如一些社交网络,例如FacebookLinkedinInfo.plist 文件中创建一个 key 。

Info.plist 包含应用程序的许多其他设置,必须提交。

如何安全我的 key 并正常提交Info.plist

Info.plist 示例(CFBundleURLSchemesFacebookAppID)

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb355414950742780</string>
            </array>
        </dict>
    </array>
<key>FacebookAppID</key>
<string>355414950742780</string>

最佳答案

尝试并从不推送 Info.plist 风险太大文件。
对其进行版本化( git rm --cached <File> 并添加到 .gitignore )会更安全

然后你可以使用 content filter driver , 使用 .gitattributes declaration :

注册 smudge脚本,它将生成包含关于 git checkout 的敏感信息的文件.

enter image description here (图片来自“Customizing Git - Git Attributes”,来自“Pro Git book”)

那 ' smudge ' 脚本(您必须编写的)需要:

  • 获取 key (从存储库外部的来源,这样就没有错误添加和推送的风险)
  • 生成Info.plist文件,使用跟踪的模板 Info.plist.tpl其中包含要替换的占位符值。

这意味着:

  • 模板Info.plist.tpl被添加到 git 仓库
  • 生成文件Info.plist.gitignore 中声明文件并且从不进行版本控制(并且从不推送)。

关于ios - 如何在 GitHub 中保存或安全避免 Facebook 或 LinkedIn 等社交网络的 key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34471477/

相关文章:

ios - 在 C 回调中快速转换 UnsafeMutablePointer<Void>

android - 无法获取提供者 com.facebook.internal.FacebookInitProvider : java. lang.ClassNotFoundException

android - 使用 Facebook SDK 4.1 在 Facebook 上共享带有文本故事的图像

facebook - 连续运行流量检查(flowtype)

git add 命令失败并继续运行

Github 在等待 pull 请求时在 fork 上工作

ios - 快速将两个字典添加到同一个数组中

ios - 如何通过滑动手势以编程方式切换 View Controller ?

android - Release模式下应用程序的日志消息

java - 如何将 gradle 多项目存储库作为 git 子模块包含在另一个 gradle 项目中