Bitbucket 인증 공급자(Bitbucket Authentication Provider)
Backstage core-plugin-api 패키지에는 Bitbucket Cloud를 사용해 사용자를 인증할 수 있는 Bitbucket 인증 공급자가 포함되어 있습니다. 이는 Bitbucket Server에서는 작동하지 않습니다.
출처: 문서
본문
Backstage core-plugin-api 패키지에는 Bitbucket Cloud를 사용해 사용자를 인증할 수 있는 Bitbucket 인증 공급자가 포함되어 있습니다. 이는 Bitbucket Server에서는 작동하지 않습니다.
Bitbucket에서 OAuth Consumer 만들기
Bitbucket Cloud 인증을 추가하려면 OAuth Consumer를 만들어야 합니다.
https://bitbucket.org/<your-project-name>/workspace/settings/api로 이동하세요.
Add Consumer를 클릭하세요.
로컬 개발 설정:
-
Application name: Backstage(또는 커스텀 앱 이름)
-
Callback URL:
http://localhost:7007/api/auth/bitbucket -
나머지는 선택 사항입니다.
-
(중요) Permissions: Account - Read, Workspace membership - Read
구성
공급자 구성은 루트 auth 구성 아래의 app-config.yaml에 추가할 수 있습니다.
auth: environment: development providers: bitbucket: development: clientId: ${AUTH_BITBUCKET_CLIENT_ID} clientSecret: ${AUTH_BITBUCKET_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 signIn: resolvers: # See https://backstage.io/docs/auth/bitbucket/provider#resolvers for more resolvers
Bitbucket 공급자는 두 개의 구성 키를 가진 구조입니다.
-
clientId: Bitbucket에서 생성한 Key. 예:b59241722e3c3b4816e2 -
clientSecret: 생성된 Key에 연결된 Secret.
선택 사항
sessionDuration: 사용자 세션의 수명.
리졸버
이 공급자는 바로 사용할 수 있는 여러 리졸버를 포함합니다.
-
emailMatchingUserEntityProfileEmail: auth 공급자의 이메일 주소를 일치하는spec.profile.email을 가진 User 엔티티와 매칭합니다. 일치하는 항목이 없으면NotFoundError를 던집니다. -
emailLocalPartMatchingUserEntityName: auth 공급자의 이메일 주소의 로컬 부분을 일치하는name을 가진 User 엔티티와 매칭합니다. 일치하는 항목이 없으면NotFoundError를 던집니다. -
userIdMatchingUserEntityAnnotation: auth 공급자의userId를 일치하는bitbucket.org/user-id어노테이션을 가진 User 엔티티와 매칭합니다. 일치하는 항목이 없으면NotFoundError를 던집니다. -
usernameMatchingUserEntityAnnotation: auth 공급자의username을 일치하는bitbucket.org/username어노테이션을 가진 User 엔티티와 매칭합니다. 일치하는 항목이 없으면NotFoundError를 던집니다.
note
리졸버는 순서대로 시도되지만 NotFoundError를 던질 때만 건너뜁니다.
이 리졸버들이 요구 사항에 맞지 않는다면 커스텀 리졸버를 만들 수 있습니다. 이는 Sign-in Identities and Resolvers 문서의 Building Custom Resolvers 섹션에서 다룹니다.
백엔드 설치
공급자를 백엔드에 추가하려면 먼저 다음 명령을 실행해 패키지를 설치해야 합니다.
Backstage 루트 디렉토리에서
yarn --cwd packages/backend add @backstage/plugin-auth-backend-module-bitbucket-provider
그런 다음 다음 줄을 추가해야 합니다.
packages/backend/src/index.ts에
backend.add(import('@backstage/plugin-auth-backend'));backend.add(import('@backstage/plugin-auth-backend-module-bitbucket-provider'));
공급자를 Backstage 프론트엔드에 추가하기
프론트엔드에 공급자를 추가하려면 bitbucketAuthApi 참조와 SignInPage 컴포넌트를 Adding the provider to the sign-in page에 표시된 대로 추가하세요.