본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Provider: BeyondTrust Password Safe

원문 보기 위키 갱신

External Secrets Operator는 BeyondTrust Password Safe와 통합됩니다. BeyondInsight/Password Safe 23.1 이상에서 시크릿을 가져올 수 있어요.

출처: External Secrets

본문

경고: External Secrets Operator를 안전하게 쓰려면 여러 조치가 필요합니다. 자세한 내용은 Security Best Practices를 참고하세요.경고: BT 프로바이더 시크릿이 삭제되어도 Kubernetes 시크릿에는 여전히 남아 있습니다.

사전 준비 (Prerequisites)

BT 프로바이더는 BeyondInsight/Password Safe 23.1 이상에서 시크릿 조회를 지원합니다.이 프로바이더가 시크릿을 가져오려면 Password Safe/Secrets Safe 인스턴스에 해당 시크릿이 미리 구성되어 있고, 읽기 권한이 부여되어 있어야 합니다.

인증 (Authentication)

BeyondTrust OAuth 인증 방식입니다.1. BeyondInsight에서 API access registration 생성 2. Secrets Safe 그룹을 새로 만들거나 기존 것 사용 3. Application User를 새로 만들거나 기존 것 사용 4. Application user에 API registration 추가 5. 사용자를 그룹에 추가 6. 그룹에 Secrets Safe 기능 추가참고: ClientID와 ClientSecret은 SecretStore가 설정을 읽을 수 있도록 Kubernetes 시크릿에 저장해야 합니다.클라이언트 자격 증명(client credentials) 인증을 쓴다면:

kubectl create secret generic bt-secret --from-literal ClientSecret=your secret
kubectl create secret generic bt-id --from-literal ClientId=your ID

API Key 인증을 쓴다면:

kubectl create secret generic bt-apikey --from-literal ApiKey=your apikey

클라이언트 인증서 (Client Certificate)

retrievalType: MANAGED_ACCOUNT을 쓴다면 Secrets Safe에서 pfx 인증서를 다운로드해, 그 인증서를 추출하고 Kubernetes 시크릿 두 개를 만들어야 합니다.

openssl pkcs12 -in client_certificate.pfx -nocerts -out ps_key.pem -nodes
openssl pkcs12 -in client_certificate.pfx -clcerts -nokeys -out ps_cert.pem

# Copy the text from the ps_key.pem to a file.
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----

# Copy the text from the ps_cert.pem to a file.
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----

kubectl create secret generic bt-certificate --from-file=ClientCertificate=./ps_cert.pem
kubectl create secret generic bt-certificatekey --from-file=ClientCertificateKey=./ps_key.pem

SecretStore 만들기

아래 예시를 따라 SecretStore 리소스를 만들 수 있어요. 모든 네임스페이스에서 시크릿을 참조할 수 있게 해주는 ClusterSecretStore도 사용할 수 있습니다.

kubectl apply -f secret-store.yml
apiVersion: external-secrets.io/v1
kind: SecretStore
metadata:
  name: secretstore-beyondtrust
spec:
  provider:
    beyondtrust:
      server:
        apiUrl: https://example.com/BeyondTrust/api/public/v3/
        retrievalType: MANAGED_ACCOUNT  # or SECRET
        separator: / # folder separator used to split remoteRef.key paths; defaults to /
        decrypt: true # SECRET retrievalType only: when false the password field is omitted; defaults to true
        verifyCA: true
        clientTimeOutSeconds: 45
        apiVersion: 3.0 # The recommended version is 3.1. If no version is specified, the default API version 3.0 will be used.
      auth:
        certificate: # omit certificates if retrievalType is SECRET
          secretRef:
            name: bt-certificate
            key: ClientCertificate
        certificateKey:
          secretRef:
            name: bt-certificatekey
            key: ClientCertificateKey
        clientSecret: # define this section if using client credentials authentication
          secretRef:
            name: bt-secret
            key: ClientSecret
        clientId: # define this section if using client credentials authentication
          secretRef:
            name: bt-id
            key: ClientId
        apiKey: # define this section if using Api Key authentication
          secretRef:
            name: bt-apikey
            key: ApiKey

ExternalSecret 만들기

아래 예시를 따라 ExternalSecret 리소스를 만들 수 있습니다. 시크릿은 경로(path)로 참조됩니다. 모든 네임스페이스에서 시크릿을 참조할 수 있게 하는 ClusterExternalSecret도 쓸 수 있어요.remoteRef.key는 시크릿 또는 managed-account 경로입니다. 경로 세그먼트는 스토어에 구성된 구분자(기본 /)로 이어집니다. 예) system01/managed_account01. 각 시크릿은 data 아래에 명시적으로 참조하세요. dataFrom은 지원되지 않습니다(Limitations 참고).

kubectl apply -f external-secret.yml
apiVersion: external-secrets.io/v1
kind: ExternalSecret
metadata:
 name: beyondtrust-external-secret
spec:
 refreshInterval: 1h0m0s
 secretStoreRef:
   kind: SecretStore
   name: secretstore-beyondtrust
 target:
   name: my-beyondtrust-secret # name of secret to create in k8s secrets (etcd)
   creationPolicy: Owner
 data:
   - secretKey: secretKey
     remoteRef:
       key: system01/managed_account01

K8s 시크릿 가져오기

# WARNING: this command will reveal the stored secret in plain text
kubectl get secret my-beyondtrust-secret -o jsonpath={.data.secretKey} | base64 --decode  echo

시크릿 만들기

아래 예시는 나중에 BeyondTrust로 밀어 넣을 Kubernetes 시크릿을 만드는 방법입니다.

kubectl apply -f beyondtrust-secret.yml
apiVersion: v1
kind: Secret
metadata:
  name: app-credentials
type: Opaque
stringData:
  password: S3cr3tP@ss

ClusterSecretStore 만들기

아래 예시는 BeyondTrust 프로바이더를 쓰도록 구성된 ClusterSecretStore를 만드는 방법입니다.

kubectl apply -f beyondtrust-cluster-secret-store.yml
apiVersion: external-secrets.io/v1
kind: ClusterSecretStore
metadata:
 name: beyondtrust-store
spec:
 provider:
   beyondtrust:
    auth:
      certificate:
        secretRef:
            name: bt-certificate
            key: ClientCertificate
      certificateKey:
        secretRef:
            name: bt-certificatekey
            key: ClientCertificateKey
      clientSecret:
        secretRef:
          name: bt-secret
          key: ClientSecret
      clientId:
        secretRef:
          name: bt-id
          key: ClientId
    server:
      retrievalType: MANAGED_ACCOUNT
      verifyCA: true
      clientTimeOutSeconds: 45
      apiUrl: https://example.com/BeyondTrust/api/public/v3/
      apiVersion: 3.1

PushSecret 만들기

아래 예시는 시크릿 데이터를 BeyondTrust로 밀어 넣는 PushSecret 리소스를 만드는 방법입니다.

kubectl apply -f beyondtrust-push-secret.yml
apiVersion: external-secrets.io/v1alpha1
kind: PushSecret
metadata:
  name: pushsecret-beyondtrust
spec:
  refreshInterval: 1h0m0s
  secretStoreRefs:
    - name: beyondtrust-store
      kind: ClusterSecretStore
  selector:
    secret:
      name: app-credentials
  data:
    - match:
        secretKey: password
        remoteRef:
          remoteKey:  # not used in Beyondtrust PushSecret
          property:  # not used in Beyondtrust PushSecret
      metadata:
        secret_type: CREDENTIAL # (FILE/CREDENTIAL/TEXT)
        title: Secret Title 505
        username: fhernandez
        description: Secret Title Description
        file_name: credentials.txt # only for FILE secret_type
        folder_name: folder1
        owner_id: 1
        group_id: 1
        owner_type: User
        notes: This is a sample note for the secret
        urls: # List of URLs associated with the secret (optional)
          - url: https://myapp.example.com/login
            id: 454
            credential_id: 25

제약 사항 (Limitations)

  • 프로바이더는 data[].remoteRef.key로 개별 시크릿을 읽고 PushSecret으로 씁니다. dataFrom.extract와 dataFrom.find는 구현되어 있지 않습니다(GetSecretMap과 GetAllSecrets가 “not implemented”를 반환). 그래서 각 시크릿을 키로 명시적으로 참조해야 해요.- deletionPolicy: Delete를 쓴 PushSecret은 지원되지 않습니다. PushSecret이나 ExternalSecret을 제거해도 BeyondTrust의 시크릿은 삭제되지 않습니다. DeleteSecret 연산이 구현되어 있지 않기 때문이에요.

더 알아보기 (Learn more)