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

Bitbucket Server 인증 공급자(Bitbucket Server Authentication Provider)

원문 보기 위키 갱신

Backstage core-plugin-api 패키지에는 Bitbucket Server를 사용해 사용자를 인증할 수 있는 Bitbucket Server 인증 공급자가 포함되어 있습니다. 이는 Bitbucket Cloud에서는 작동하지 않습니다.

출처: 문서

본문

Backstage core-plugin-api 패키지에는 Bitbucket Server를 사용해 사용자를 인증할 수 있는 Bitbucket Server 인증 공급자가 포함되어 있습니다. 이는 Bitbucket Cloud에서는 작동하지 않습니다.

Bitbucket Server 인증을 추가하려면 들어오는(incoming) 애플리케이션 링크를 만들어야 합니다. Bitbucket Server 문서에 설명된 단계를 따라 만드세요.

구성

공급자 구성은 루트 auth 구성 아래의 app-config.yaml에 추가할 수 있습니다.

auth:  environment: development  providers:    bitbucketServer:      development:        host: bitbucket.example.org        clientId: ${AUTH_BITBUCKET_SERVER_CLIENT_ID}        clientSecret: ${AUTH_BITBUCKET_SERVER_CLIENT_SECRET}        ## uncomment to set lifespan of user session        # sessionDuration: { hours: 24 } # supports `ms` library format (e.g. '24h', '2 days'), ISO duration, "human duration" as used in code

Bitbucket Server 공급자는 두 개의 구성 키를 가진 구조입니다.

  • clientId: Bitbucket이 생성한 클라이언트 ID. 예: b0f868455c15dcdff5c5fb5d173ae684.

  • clientSecret: 생성된 클라이언트 ID에 연결된 클라이언트 시크릿.

선택 사항

  • sessionDuration: 사용자 세션의 수명.

리졸버

이 공급자는 바로 사용할 수 있는 여러 리졸버를 포함합니다.

  • emailMatchingUserEntityProfileEmail: auth 공급자의 이메일 주소를 일치하는 spec.profile.email을 가진 User 엔티티와 매칭합니다. 일치하는 항목이 없으면 NotFoundError를 던집니다.

  • emailLocalPartMatchingUserEntityName: auth 공급자의 이메일 주소의 로컬 부분을 일치하는 name을 가진 User 엔티티와 매칭합니다. 일치하는 항목이 없으면 NotFoundError를 던집니다.

note

리졸버는 순서대로 시도되지만 NotFoundError를 던질 때만 건너뜁니다.

이 리졸버들이 요구 사항에 맞지 않는다면 커스텀 리졸버를 만들 수 있습니다. 이는 Sign-in Identities and Resolvers 문서의 Building Custom Resolvers 섹션에서 다룹니다.

백엔드 설치

공급자를 백엔드에 추가하려면 먼저 다음 명령을 실행해 패키지를 설치해야 합니다.

Backstage 루트 디렉토리에서

yarn --cwd packages/backend add @backstage/plugin-auth-backend-module-bitbucket-server-provider

그런 다음 다음 줄을 추가해야 합니다.

packages/backend/src/index.ts

//...backend.add(import('@backstage/plugin-auth-backend'));backend.add(  import('@backstage/plugin-auth-backend-module-bitbucket-server-provider'),);//...

프론트엔드 구성

로그인

프론트엔드에 공급자를 추가하려면 bitbucketServerAuthApiRef 참조와 SignInPage 컴포넌트를 Adding the provider to the sign-in page에 표시된 대로 추가하세요.

ScmAuth

Backstage가 로그인한 사용자의 OAuth 토큰을 사용해 Bitbucket Server API에 접근할 수 있게 하려면, Custom ScmAuthApi Implementation에 표시된 대로 ScmAuth.forBitbucketServer 메서드를 사용해 ScmAuth 공급자 목록에 추가해야 합니다.

더 알아보기 (Learn more)