允许无范围的隐式 OAuth - IdentityServer4

Allowing Implicit OAuth without scope - IdentityServer4

嗨,

我创建了 identityServer4 来保护我们的 API。我们希望允许我们的一位客户在不发送范围参数的情况下进行连接。

目前,他可以通过发送如下查询参数进行登录: https://IP/connect/authorize?response_type=token&client_id=2b62b08868144d68bdd6112d1933b945&state=xyz&scope=general&redirect_uri=https://IP/Test

如果他发送没有范围的请求,服务器会抛出无效范围错误。

以下为客户声明

 new Client
 {
   ClientId="2b62b08868144d68bdd6112d1933b945",
   ClientName = "Client 2",
   ClientSecrets = new [] { new Secret("secret".Sha256()) },
   AllowedGrantTypes = GrantTypes.ImplicitAndClientCredentials,
   AllowAccessTokensViaBrowser = true,
   RedirectUris = { Settings.RedirectURL },
   RequireClientSecret = false,
   PostLogoutRedirectUris = { Settings.PostLogoutRedirectUris },
   AllowedScopes = { "general" },
   RequirePkce = true,
   AllowRememberConsent = true,
   AlwaysIncludeUserClaimsInIdToken = true,
   Enabled = true,
   AlwaysSendClientClaims = true
  }

对于 OpenID Connect,openid 范围是必需的范围,所有其他范围都是可选的。代表IDToken,必填。

授权端点需要范围,这是文档参考: https://identityserver4.readthedocs.io/en/latest/endpoints/authorize.html?highlight=Scope#authorize-endpoint

以后可能会在 IDS4 上考虑此功能参考:https://github.com/IdentityServer/IdentityServer4/issues/4556#issuecomment-654593955