谷歌认证提供商
Backstagecore-plugin-api
软件包自带一个 Google 身份验证提供程序,可使用 Google OAuth 对用户进行身份验证。
创建 OAuth 证书
要支持 Google 身份验证,必须创建 OAuth 凭据:
- Log in to the Google Console 2. Select or create a new project from the dropdown menu on the top bar 3. Navigate to APIs & Services > Credentials 4. Click Create Credentials and choose
OAuth client ID
5. Configure an OAuth consent screen, if required - For local development, you do not need to enter any Authorized domain - For scopes, selectopenid
,auth/userinfo.email
andauth/userinfo.profile
- Add yourself as a test user, if using External user type 6. Set Application Type toWeb Application
with these settings: -Name
: Backstage (or your custom app name) -Authorized JavaScript origins
: http://localhost:3000 -Authorized Redirect URIs
: http://localhost:7007/api/auth/google/handler/frame 7. Click Create
配置
然后就可以将提供程序配置添加到您的app-config.yaml
根目录下auth
配置:
auth:
environment: development
providers:
google:
development:
clientId: ${AUTH_GOOGLE_CLIENT_ID}
clientSecret: ${AUTH_GOOGLE_CLIENT_SECRET}
谷歌提供商是一个包含两个配置键的结构:
clientId
: 生成的客户端 ID,例如10023341500512-beui241gjwwkrdkr2eh7dprewj2pp1q.apps.googleusercontent.com
*clientSecret
: 与生成的客户端 ID 绑定的客户端Secret。
将提供程序添加到 Backstage 前端
要将提供程序添加到前端,请添加googleAuthApi
参考和SignInPage
如图所示将提供商添加到登录页面.