尧图网站设计 尧图网站设计YAOTU DESIGN
ARTICLE DETAIL

资讯详情

深耕网站设计与一线实操的经验洞察。

Backstage v1.28.0-next.3 更新解读:OAuth 作用域管理重构与 GitHub 命名清理

Backstage v1.28.0-next.3 更新解读:OAuth 作用域管理重构与 GitHub 命名清理 Backstage v1.28.0-next.3 更新解读OAuth 作用域管理重构与 GitHub 命名清理【免费下载链接】backstageBackstage is an open framework for building developer portals项目地址: https://gitcode.com/GitHub_Trending/ba/backstage本篇指南以 v1.28.0-next.3 版本变更日志 为主体系统梳理该预发布版本中涉及开发者的关键变更包括 OAuth Provider 全新additionalScopes作用域管理体系、backstage/integration中 GitHub 旧命名 API 的最终移除、URL Reader 功能从backend-common向backend-defaults的迁移以及 OneLogin Provider 独立模块化等。阅读完成后你将掌握本次升级所需的全部迁移动作、配置改写方案与踩坑点能够平滑地将应用升级到 1.28.0 系列。说明v1.28.0-next.3属于正式发布前的滚动预发布版本next 系列文中所涉及的版本号、依赖版本与 API 形态以当前仓库实际内容为准。正式升级前请留意后续 release 是否存在进一步调整。一、版本概览与升级入口该变更日志覆盖 Backstage monorepo 中 90 余个包的版本更新核心变化集中在三个方向破坏性变更BREAKINGbackstage/integration移除 GitHub 旧命名 API多个 OAuth Provider 模块移除scope/scopes配置项。架构性迁移URL Reader 全部功能从backstage/backend-common迁至backstage/backend-defaults/urlReaderOneLogin Provider 独立成模块。能力新增CLI 新增repo fix --publish发布元数据校验backstage/backend-defaults对外暴露DefaultSchedulerService用户设置插件开始使用 signals 跨会话同步。升级工具链接位于文档头部https://backstage.github.io/upgrade-helper/?to1.28.0-next.3可基于该工具自动生成依赖升级清单。需要说明的是该链接指向外部服务仓库内未内置其实现依赖版本对照表以日志正文的 Updated dependencies 各节为准。二、backstage/integration1.12.0-next.1GitHub 旧命名 API 正式移除2.1 破坏性变更内容本次变更commitbe1014d移除了约两年前将命名从GitHub改为Github时遗留的全部废弃代码。受影响函数与替换关系如下已移除旧命名替代 API新命名getGitHubFileFetchUrlgetGithubFileFetchUrlGitHubIntegrationConfigGithubIntegrationConfigGitHubIntegrationGithubIntegrationreadGitHubIntegrationConfigreadGithubIntegrationConfigreadGitHubIntegrationConfigsreadGithubIntegrationConfigsreplaceGitHubUrlTypereplaceGithubUrlType2.2 源码佐证从当前仓库 packages/integration/src/github/core.ts 可以看出新命名 API 已是唯一实现import { GithubIntegrationConfig } from ./config; export function getGithubFileFetchUrl( url: string, config: GithubIntegrationConfig, ) { ... }所有对旧命名的引用均已在源码中清除仅存在于report.api.md与CHANGELOG.md的历史记录中。升级动作全仓库搜索GitHubIntegration/getGitHubFileFetchUrl等旧命名并批量替换为大写H变为小写h的新命名即可由于这是纯符号重命名无行为差异。2.3 附带修复commit23ee9ab修复 AWS CodeCommit 集成允许修改 host该修复同时同步到backstage/backend-common与backstage/integration-react。依赖同步升级backstage/config1.2.0、backstage/errors1.2.4。三、OAuth 作用域管理重构additionalScopes统一体系核心变更这是本次版本中影响面最大的架构调整贯穿plugin-auth-node与全部 OAuth Provider 模块。3.1 旧配置的移除以下 Provider 模块的scope或scopes配置项被移除统一替换为标准additionalScopes配置模块变化详情plugin-auth-backend-module-atlassian-provider0.2.0-next.2scope/scopes移除offline_access、read:jira-work、read:jira-user设为必选plugin-auth-backend-module-oauth2-provider0.2.0-next.2scope移除替换为additionalScopesplugin-auth-backend-module-oidc-provider0.2.0-next.3scope移除openid、profile、email设为必选plugin-auth-backend-module-vmware-cloud-provider0.2.0-next.2scope移除openid、offline_access设为必选plugin-auth-backend-module-pinniped-provider0.1.13-next.2scope移除openid、pinniped:request-audience、username、offline_access设为必选其余 Providergithub、gitlab、google、bitbucket、microsoft、okta 等同步新增对additionalScopes的支持并各自声明了始终存在的必选作用域GitHubread:userGitLabread_userGoogleopenid、userinfo.email、userinfo.profileBitbucketaccountOktaopenid、email、profile、offline_accessMicrosoft仅新增additionalScopes支持3.2 新配置写法配置层面在app-config.yaml的对应 auth provider 节点下使用数组形式auth: providers: github: development: clientId: ${AUTH_GITHUB_CLIENT_ID} clientSecret: ${AUTH_GITHUB_CLIENT_SECRET} additionalScopes: - repo - workflow oidc: development: clientId: ${AUTH_OIDC_CLIENT_ID} clientSecret: ${AUTH_OIDC_CLIENT_SECRET} additionalScopes: - offline_access代码层面createOAuthProviderFactory新增additionalScopes选项并会从 auth provider 配置中读取同名配置项两者共同生效。源码证据位于 plugins/auth-node/src/oauth/createOAuthProviderFactory.tsexport function createOAuthProviderFactoryTProfile(options: { authenticator: OAuthAuthenticatorunknown, TProfile; additionalScopes?: string[]; stateTransform?: OAuthStateTransform; profileTransform?: ProfileTransformOAuthAuthenticatorResultTProfile; signInResolver?: SignInResolverOAuthAuthenticatorResultTProfile; ... }): AuthProviderFactory { ... return createOAuthRouteHandlersTProfile({ authenticator: options.authenticator, ... additionalScopes: options.additionalScopes, ... }); }3.3createOAuthAuthenticator新的 scopes 选项commit798ec37重构了 OAuth 作用域管理plugins/auth-node/src/oauth/types.ts 中createOAuthAuthenticator的定义保持不变仍是纯类型透传函数真正的行为变化落在路由处理器与作用域合并逻辑上scopes.persist是否持久化作用域替代旧的shouldPersistScopes选项。scopes.required必选作用域列表将始终被请求。scopes.transform在发起请求前对作用域做转换的函数。3.4 底层行为变更已授权作用域的合并语义这是本次重构最容易被忽视的行为差异。变更前完整授权authorization流程不包含已授予的既有作用域刷新refresh流程仅包含既有作用域。变更后持久化作用域的 Provider 在授权与刷新流程中都会将已授予的作用域与本次请求的作用域合并merge。这意味着用户先前已授权的权限在后续登录中会持续保留避免因作用域列表变化导致的能力丢失。从实现结构看作用域合并逻辑位于 plugins/auth-node/src/oauth/CookieScopeManager.ts该文件同时配套了 CookieScopeManager.test.ts 测试用例Cookie 中保存的已授权作用域会在新请求中参与合并计算。升级动作若你的自定义 Provider 通过shouldPersistScopes控制持久化请迁移为scopes.persist若通过scopes.transform做过作用域裁剪请验证合并语义变化后结果是否符合预期。四、URL Reader 迁移backend-common → backend-defaults4.1 功能迁移commitb2ee7f3将全部 URL reader 功能从backstage/backend-common迁至backstage/backend-defaults/urlReader。升级动作更新 import 路径。同时backstage/backend-plugin-api废弃了全部 URL Reader 相关类型名替换为带UrlReaderService前缀的新命名旧类型名新类型名ReadTreeOptionsUrlReaderServiceReadTreeOptionsReadTreeResponseUrlReaderServiceReadTreeResponseReadTreeResponseDirOptionsUrlReaderServiceReadTreeResponseDirOptionsReadTreeResponseFileUrlReaderServiceReadTreeResponseFileReadUrlResponseUrlReaderServiceReadUrlResponseReadUrlOptionsUrlReaderServiceReadUrlOptionsSearchOptionsUrlReaderServiceSearchOptionsSearchResponseUrlReaderServiceSearchResponseSearchResponseFileUrlReaderServiceSearchResponseFile该废弃发生在backstage/backend-plugin-api0.6.19-next.3属于渐进式迁移先废弃旧名、提供新名后续版本再移除。4.2 backend-defaults 的其他变化commit1897169backstage/backend-defaults0.3.0-next.3对外暴露DefaultSchedulerService配套地backstage/backend-tasks的废弃提示信息更详细。commit8aab451数据库连接器database connectors内部小幅重构无对外行为变化。五、OneLogin Provider 独立成模块commit566d7cb将 OneLogin Provider 从backstage/plugin-auth-backend中拆分出来成为独立模块backstage/plugin-auth-backend-module-onelogin-provider0.1.0-next.0。对应地backstage/plugin-auth-backend0.22.6-next.3改为依赖新模块commit3e1bb15Updated to use the newbackstage/plugin-auth-backend-module-onelogin-providerimplementation。升级动作若你的后端直接引用 OneLogin provider 实现需将依赖从backstage/plugin-auth-backend改为backstage/plugin-auth-backend-module-onelogin-provider。新后端系统new backend system下通过以下方式注册backend.add(import(backstage/plugin-auth-backend-module-onelogin-provider));六、CLI 与工具链改进6.1repo fix新增--publish标志commitc328131为backstage/cli0.26.7-next.3的repo fix命令新增--publish标志yarn backstage-cli repo fix --publish该命令会校验并在可能的情况下生成使用 Backstage CLI 发布包所需的元数据。同时新增发布前检查打包发布时package.json中必须存在backstage.pluginId与backstage.pluginPackage(s)字段。配套地backstage/cli-node的BackstagePackageJson类型新增了这些 plugin metadata 字段。6.2 cli-common 与测试工具commit142abb0backstage/cli-common的 monorepo 根目录检测findPaths现在接受package.json中的简写workspaces配置字符串数组形式不再强制要求workspaces.packages对象形式。commit006b3e8backstage/backend-test-utils将类型MockDirectoryOptions重命名为CreateMockDirectoryOptions明确其仅用于 mock 目录工厂。commit9bdc3e8backstage/backend-plugin-api在测试中访问ExtensionPoint.T属性时返回null而非抛错避免针对该属性的测试被轻易破坏。6.3 create-app 模板调整commit1a212f9脚手架生成的 app 侧边栏移除 Tech Radar 菜单项以对齐后端移除 tech-radar 插件的变化。commit34daaea修复 node-postgres 文档的失效链接。七、插件功能更新与 UI 修复7.1 scaffolderEntityPicker 展示方式变更backstage/plugin-scaffolder1.21.0-next.3commitd57ebbcEntityPicker 中实体的展示方式从humanizeEntityRef改为使用entityPresentationApi。这使实体展示与 Catalog 其他位置保持一致的呈现规则图标、标题、副标题等。7.2 用户设置跨会话同步backstage/plugin-user-settings、plugin-user-settings-backend及新增的plugin-user-settings-commoncommite6ec179开始使用 signals 在多个会话/标签页间实时同步用户设置变更同时新增共享 common 包。7.3 UI 层修复汇总core-components59cee81OverflowTooltip 底层 Typography 组件改用inheritvariant83c4251status 组件新增图标。plugin-cataloge04e57d修复给 catalog 表格添加pagination属性后 Actions 列丢失的问题。plugin-catalog-react/plugin-scaffolder-reactfa8560e修复 Autocomplete 下拉框悬停时与侧边栏重叠的问题。plugin-catalog-graph8d474d3EntityRelationsGraph过滤器新增从图中排除实体的函数。plugin-scaffolder-backendf4c8486debug:waitaction 最大等待时间提升至 10 分钟。八、升级操作清单综合以上变更升级到 v1.28.0 系列以 next.3 为参照时建议按序执行替换 GitHub 旧命名getGitHubFileFetchUrl→getGithubFileFetchUrlGitHubIntegration→GithubIntegration等 6 个符号。改写 OAuth 作用域配置将各 Provider 的scope/scopes配置改为additionalScopes数组自定义 Provider 若使用shouldPersistScopes则改用scopes.persist确认必选作用域required scopes与既有授权作用域合并后的实际权限范围。迁移 URL Reader import从backstage/backend-common迁移到backstage/backend-defaults/urlReader并将旧类型名替换为UrlReaderService*新命名。OneLogin 依赖调整将 OneLogin provider 的依赖与 import 迁移到backstage/plugin-auth-backend-module-onelogin-provider。发布包元数据使用yarn backstage-cli repo fix --publish校验/生成发布元数据确保backstage.pluginId、backstage.pluginPackage(s)字段存在。全量依赖升级以日志中各包的 Updated dependencies 为准同步升级涉及backend-plugin-api、plugin-auth-node、integration、core-components、catalog-react等核心依赖链。九、相关资源完整变更日志docs/releases/v1.28.0-next.3-changelog.mdGitHub 集成实现packages/integration/src/github/core.tsOAuth Provider 工厂plugins/auth-node/src/oauth/createOAuthProviderFactory.tsOAuth 作用域 Cookie 管理plugins/auth-node/src/oauth/CookieScopeManager.ts各 Provider 模块源码plugins/auth-backend-module-github-provider、plugins/auth-backend-module-atlassian-provider、plugins/auth-backend-module-onelogin-provider 等后端默认服务packages/backend-defaults【免费下载链接】backstageBackstage is an open framework for building developer portals项目地址: https://gitcode.com/GitHub_Trending/ba/backstage创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表