GitHub OAuth 应用支持多重重定向 URI 与令牌刷新
Multiple redirect URIs and token refresh for OAuth apps
开发者注意:GitHub OAuth 应用令牌机制有变,新应用默认短期令牌,旧应用需适配刷新流程;同时新增多重定向 URI 与通配符匹配,建议检查现有应用配置,避免安全风险。
We’ve released multiple updates to the OAuth app and GitHub App platforms to support more secure app development:
我们已对 OAuth 应用和 GitHub 应用平台进行了多次更新,以支持更安全的应用程序开发:
- OAuth apps can opt in to expiring access tokens and refresh tokens.
- OAuth apps can have multiple redirect URIs.
- Both GitHub Apps and OAuth apps can enable wildcard matching for redirect URIs if needed.
- OAuth 应用可以选择使用过期访问令牌和刷新令牌。
- OAuth 应用可以有多个重定向 URI。
- GitHub 应用和 OAuth 应用都可以在需要时为重定向 URI 启用通配符匹配。
Rotating tokens for OAuth apps
OAuth 应用的令牌轮换
OAuth apps can now request a short-lived token during the user authentication flow. If an app opts in, they get an access token that lives for eight hours and a refresh token that’s valid for six months. When the access token expires, the app uses the refresh token to get a new token pair.
OAuth 应用现在可以在用户身份验证流程中请求短期令牌。如果应用选择启用,它们将获得有效期为 8 小时的访问令牌和有效期为 6 个月的刷新令牌。当访问令牌过期时,应用使用刷新令牌获取新的令牌对。
Developers can add refresh token support to their app in two ways:
开发者可以通过两种方式为其应用添加刷新令牌支持:
- Include the offline_access scope in their authentication request, which triggers the short-lived token pattern. This is how developers should test and roll out this change in their app.
- Set their app registration to always use short-lived tokens. This can be used to force old clients to update and ensure that all clients are getting short-lived tokens.
- 在其身份验证请求中包含 offline_access 范围,这会触发短期令牌模式。这是开发者应在其应用中测试和推出此更改的方式。
- 将其应用注册设置为始终使用短期令牌。这可用于强制旧客户端更新,并确保所有客户端都获得短期令牌。
Short-lived tokens are enabled by default for all new applications. If your authentication SDK doesn’t support the refresh token flow, you can disable this while updating the SDK.
所有新应用默认启用短期令牌。如果您的身份验证 SDK 不支持刷新令牌流程,您可以在更新 SDK 时禁用此功能。
For more details on how to use expiring tokens with an OAuth app, see the “Authorizing OAuth apps” documentation.
有关如何将过期令牌与 OAuth 应用一起使用的更多详细信息,请参阅“授权 OAuth 应用”文档。
Multiple redirect URI support for OAuth apps
OAuth 应用的多重重定向 URI 支持
OAuth apps can now register up to 10 redirect URIs (called “callback URIs” on GitHub), making it easier to support multiple environments, domains, or deployment configurations without creating separate apps.
OAuth 应用现在可以注册最多 10 个重定向 URI(在 GitHub 上称为“回调 URI”),从而更容易支持多个环境、域或部署配置,而无需创建单独的应用。
Developers will find a new Add redirect URI button in their application settings, which can be used to add additional URLs to match against.
开发者将在其应用程序设置中找到一个新增的“添加重定向 URI”按钮,可用于添加其他要匹配的 URL。
Wildcard matching for redirect URIs
重定向 URI 的通配符匹配
OAuth apps and GitHub Apps can now enable wildcard matching for each redirect URI configured. This can allow redirects to multiple related sites (e.g., tenanted subdomains of your app) without registering a redirect URI per tenant.
OAuth 应用和 GitHub 应用现在可以为配置的每个重定向 URI 启用通配符匹配。这可以允许重定向到多个相关站点(例如,您的应用的租户子域),而无需为每个租户注册重定向 URI。
When enabled, wildcard matching allows an authorization code (and user) to be sent from GitHub to any URL that matches a subdomain or additional path off of the redirect URI.
启用后,通配符匹配允许授权代码(和用户)从 GitHub 发送到与重定向 URI 的子域或附加路径匹配的任何 URL。
Wildcard matching can be abused if the site being redirected to does not have strong control over its routes (e.g., if it hosts user content). Review your app architecture before enabling this.
如果重定向到的站点对其路由没有严格控制(例如,如果它托管用户内容),则通配符匹配可能被滥用。在启用此功能之前,请审查您的应用架构。
Apps with only one redirect URI have wildcard matching enabled. This is a legacy behavior of GitHub that is now visible and controllable. Please review your apps and disable wildcard matching if you do not need it. This applies to all OAuth apps and any GitHub App that had a single redirect URI registered.
仅有一个重定向 URI 的应用已启用通配符匹配。这是 GitHub 的遗留行为,现在已可见且可控。请检查您的应用,如果不需要通配符匹配,请禁用它。这适用于所有 OAuth 应用以及任何注册了单个重定向 URI 的 GitHub 应用。
These improvements will all be included in GitHub Enterprise Server 3.23.
这些改进都将包含在 GitHub Enterprise Server 3.23 中。
For more information about creating and managing your app’s redirects safely, see user authorization callback URLs for GitHub Apps and creating an OAuth app.
有关安全创建和管理应用重定向的更多信息,请参阅 GitHub 应用的用户授权回调 URL 和创建 OAuth 应用。
Join the discussion in the GitHub Community.
加入 GitHub 社区中的讨论。
The post Multiple redirect URIs and token refresh for OAuth apps appeared first on The GitHub Blog.
文章《OAuth 应用的多个重定向 URI 和令牌刷新》最初出现在 GitHub 博客上。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力