Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GitHub ActionsのOIDC認証

GitHub ActionsのOIDC認証

2021年に新しく発表された、GitHub ActionsのOIDC認証機能についての紹介。

Avatar for Tomofumi Kondo

Tomofumi Kondo

March 01, 2022
Tweet

More Decks by Tomofumi Kondo

Other Decks in Programming

Transcript

  1. 2. GitHub ActionsのOIDC認証機能 1. Cloud Providerの方でGitHubの特定の組織・リポジトリ・ブランチに対して アクションを許可するロールを作成しておく 2. GitHub ActionsのジョブでJWTを発行してCloud

    Providerにリクエストし、 アクセストークンを得る 3. 得たトークンを使ってCloud ProviderのAPIを叩くなどして、Cloud Provider のリソースに対するアクション(サービスのデプロイとか)を実行する。 About security hardening with OpenID Connectより引用
  2. 3. デモ OIDC用ロールの信頼ポリシー 例(抜粋) ``` "Principal": { "Federated":"arn:aws:iam::<アカウントID>:oidc-provider/token.actions.githubusercontent.com" }, "Action":

    "sts:AssumeRoleWithWebIdentity", "Condition": { "StringEquals": { "token.actions.githubusercontent.com:sub":"repo:<GitHubの組織名>/<GitHubのリポジトリ 名>:ref:refs/heads/main", "token.actions.githubusercontent.com:aud": "sts.amazonaws.com" } } ```
  3. 3. デモ OIDC認証を使うGitHub Actionsのworkflow(抜粋) AWSから先ほど作ったロールに紐づくトークンを取得する ``` - name: configure AWS

    credentials uses: aws-actions/configure-aws-credentials@v1 with: role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-oidc-test role-session-name: testrolesession aws-region: ${{ env.AWS_REGION }} ```