Closed6

PAT(Personal access token) vs github appsのtoken (installation access token)

輝

課題

  • PAT はセキュリティ的にリスクが大きいのでやめたい
輝

結論

輝

PAT(Personal access token)

輝

github appsのtoken (installation access token)

作成の流れ

流れから書くとわりと分かりやすいため定義より流れを先に書く

  • GitHub Appsを作成する
  • 署名用の秘密鍵を生成する
  • GitHub Appsをアカウントへインストールする
  • SecretsにApp IDと秘密鍵を登録する
  • GitHub Appsトークン(installation access token)の生成

説明

  • GitHub Apps のトークンの種類

    • user access token for authentication(Ref)
    • installation access token for authentication(Ref)
      • A GitHub App that generates short-lived tokens to give to other CI/CD tools, or to pull information from a repository.

  • installation access token

    • GitHub Apps トークンと呼ぶことが多いようですが、今回は CI/CD で使うため installation access token を使うことになる
    • installation access token が PAT の代わりに使うもの
    • installation access token について(Ref1 & Ref2
      • A GitHub App can request an installation access token by using a private key with a JSON web token format out-of-band.
        An installation token identifies the app as the GitHub Apps bot, such as @jenkins-bot.
        Installation access tokens expire after a predefined amount of time (currently 1 hour).

      • If you want your app to take actions on behalf of itself, rather than a user, you should use an installation access token for authentication.

  • なぜ PAT より優位性があるか

    • 突然動かなくなるリスクがない
      • GitHub Appsに登録した秘密鍵が、勝手に失効することはありません。つまりFine-grained PATのように、突然動かなくなるリスクはありません。
    • トークンの有効期限が短い
      • installation access token は短命です。そのため万が一漏えいしても、影響は時限的です。「長命な秘密鍵」と「短命なトークン」という組み合わせは強力です。秘密鍵さえ守れば、インシデント発生時の被害はかなり小さくなります。これは長命なPATでは実現できない大きな魅力です。

installation access token の生成方法

More: About GitHub Apps

このスクラップは2024/09/30にクローズされました