Skip to main content

Configuring OpenID Connect in Octopus Deploy

Use OpenID Connect within your workflows to authenticate with Octopus Deploy.

Overview

OpenID Connect (OIDC) allows your GitHub Actions workflows to authenticate with Octopus Deploy to push packages, create releases or trigger deployments without storing Octopus Deploy passwords or API keys as long-lived GitHub secrets.

This guide provides an overview of how to configure Octopus Deploy to trust GitHub's OIDC as a federated identity, and includes a workflow example for the octopusdeploy/login action that uses tokens to authenticate to your Octopus Deploy instance.

Prerequisites

  • GitHub가 OIDC(OpenID Connect)를 사용하는 방법과 아키텍처 및 이점에 대한 기본 개념을 알아보려면 OpenID Connect을(를) 참조하세요.

  • 계속하기 전에 액세스 토큰이 예측 가능한 방식으로만 할당되도록 보안 전략을 계획해야 합니다. 클라우드 공급자가 액세스 토큰을 발급하는 방법을 제어하려면 신뢰할 수 없는 리포지토리가 클라우드 리소스에 대한 액세스 토큰을 요청할 수 없도록 하나 이상의 조건을 정의해야 합니다. 자세한 내용은 OpenID Connect을(를) 참조하세요.

Adding the identity provider to Octopus Deploy

To use OIDC with Octopus Deploy, first establish a trust relationship between GitHub Actions and your Octopus Deploy instance. For more information about this process, see Using OpenID Connect with the Octopus API in the Octopus Deploy documentation.

  1. Sign in to your Octopus Deploy instance.
  2. Create or open the Service Account that will be granted access via the token request.
  3. Configure a new OIDC Identity, defining the relevant subject that the GitHub Actions workflow token request will be validated against.

Updating your GitHub Actions workflow

To update your workflows for OIDC, you will need to make two changes to your YAML:

  1. Add permissions settings for the token.
  2. Use the OctopusDeploy/login action to exchange the OIDC token (JWT) for a cloud access token.

참고 항목

워크플로 또는 OIDC 정책에서 환경을 사용하는 경우 추가 보안을 위해 환경에 보호 규칙을 추가하는 것이 좋습니다. 예를 들어 환경에 배포할 수 있는 분기 및 태그를 제한하거나 환경 비밀에 액세스하도록 환경에 대한 배포 규칙을 구성할 수 있습니다. 자세한 내용은 배포 환경 관리을(를) 참조하세요.

Adding permissions settings

작업 또는 워크플로 실행에는 GitHub의 OIDC 공급자가 모든 실행에 대한 JSON 웹 토큰을 만들 수 있는 id-token: write이 있는 permissions 설정이 필요합니다.

참고 항목

워크플로 권한에서 id-token: write을 설정해도 워크플로에 리소스를 수정하거나 쓸 수 있는 권한이 부여되지는 않습니다. 대신 워크플로는 작업이나 단계의 OIDC 토큰을 요청(가져오기)하고 사용(설정)하는 것만 허용합니다. 이 토큰은 수명이 짧은 액세스 토큰을 사용하여 외부 서비스에 인증하는 데 사용됩니다.

필요한 권한, 구성 예, 고급 시나리오에 대한 자세한 내용은 OpenID 연결 참조을(를) 참조하세요.

Requesting the access token

The OctopusDeploy/login action receives a JWT from the GitHub OIDC provider, and then requests an access token from your Octopus Server instance. For more information, see the OctopusDeploy/login documentation.

The following example exchanges an OIDC ID token with your Octopus Deploy instance to receive an access token, which can then be used to access your Octopus Deploy resources. Be sure to replace the server and service_account_id details appropriately for your scenario.

YAML
# 이 워크플로는 GitHub에서 인증되지 않은 작업을 사용합니다.
# 작업은 타사에서 제공하며
# 별도의 서비스 약관, 개인정보처리방침, 지원 설명서에서 규정됩니다.
# 참조하세요.

jobs:
  create_release_in_octopus:
    runs-on: ubuntu-latest
    name: Create a release in Octopus
    permissions:
      # You might need to add other permissions here like `contents: read` depending on what else your job needs to do
      id-token: write # This is required to obtain an ID token from GitHub Actions for the job
    steps:
      - name: Login to Octopus
        uses: OctopusDeploy/login@34b6dcc1e86fa373c14e6a28c5507d221e4de629 #v1.0.2
        with:
          server: https://my.octopus.app
          service_account_id: 5be4ac10-2679-4041-a8b0-7b05b445e19e

      - name: Create a release in Octopus
        uses: OctopusDeploy/create-release-action@fe13cc69c1c037cb7bb085981b152f5e35257e1f #v3.2.2
        with:
          space: Default
          project: My Octopus Project

Further reading