OpenIddict 问题
OpenIddict problems
我在离开项目很长时间(可能超过一年)后才回到项目,在将 VS2017 更新到版本 15.7.5 后,我在尝试重建项目时遇到了很多问题。第一个问题是 nuget 依赖项抱怨 OpenIddict 程序集“1.0.0.-*”被请求但收到“1.0.0-rtm-1063”。这些错误对我来说毫无意义,但我修改了我的 .csproj 文件,如下所示:
<!-- OpenIdDict -->
<!-- 1.0.0.-* changed to 1.0.0.-rtm-1063 -->
<PackageReference Include="AspNet.Security.OAuth.Validation" Version="1.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.1" />
<PackageReference Include="OpenIddict" Version="1.0.0-rtm-1063" />
<PackageReference Include="OpenIddict.EntityFrameworkCore" Version="1.0.0-rtm-1063" />
<PackageReference Include="OpenIddict.Mvc" Version="1.0.0-rtm-1063" />
这显然不是一个好的永久解决方案(什么是正确的解决方案?)加上这导致了一系列其他问题,这些问题通过替换
得到解决
using OpenIddict.Models;
和
using OpenIddict.EntityFrameworkCore.Models;
这给我留下了两个我找不到解决方案的问题。
services.AddOpenIddict().AddEntityFrameworkCoreStores<ApplicationDbContext>()
未定义。
Configure()方法中对app.UseOpenIddict()的调用;抱怨 UseOpenIddict 未定义。
如果有人能为我指明解决这些问题的正确方向,我将不胜感激。
此外,该项目使用的是 .NET Core 1.1,据我所知,它已被 .NET Core 2.1 取代。我不清楚如何升级项目以使用 .NET Core 2.1。 VS2017 GUI 中的下拉列表仅包含 1.0 和 1.1 以及 "Install Other Frameworks..." 但是即使安装了最新的 2.1 SDK 和运行时,下拉列表中仍然没有 .NET Core 2.1 的选项。我做错了什么?
您应该删除 <PackageReference Include="AspNet.Security.OAuth.Validation" Version="1.0.0" />
,因为它现在被 OpenIddict
元包传递引用。
在 RC3 中,语法发生了一些变化,因此 services.AddOpenIddict().AddEntityFrameworkCoreStores<ApplicationDbContext>()
现在不再有效:
// In OpenIddict RC2, all the options used to be grouped.
services.AddOpenIddict(options =>
{
options.AddEntityFrameworkCoreStores<ApplicationDbContext>();
options.AddMvcBinders();
options.EnableAuthorizationEndpoint("/connect/authorize")
.EnableLogoutEndpoint("/connect/logout")
.EnableTokenEndpoint("/connect/token")
.EnableUserinfoEndpoint("/api/userinfo");
options.AllowAuthorizationCodeFlow()
.AllowPasswordFlow()
.AllowRefreshTokenFlow();
options.RegisterScopes(OpenIdConnectConstants.Scopes.Email,
OpenIdConnectConstants.Scopes.Profile,
OpenIddictConstants.Scopes.Roles);
options.RequireClientIdentification();
options.EnableRequestCaching();
options.EnableScopeValidation();
options.DisableHttpsRequirement();
});
// In OpenIddict RC3, the options are now split into 3 categories:
// the core services, the server services and the validation services.
services.AddOpenIddict()
.AddCore(options =>
{
// AddEntityFrameworkCoreStores() is now UseEntityFrameworkCore().
options.UseEntityFrameworkCore()
.UseDbContext<ApplicationDbContext>();
})
.AddServer(options =>
{
// AddMvcBinders() is now UseMvc().
options.UseMvc();
options.EnableAuthorizationEndpoint("/connect/authorize")
.EnableLogoutEndpoint("/connect/logout")
.EnableTokenEndpoint("/connect/token")
.EnableUserinfoEndpoint("/api/userinfo");
options.AllowAuthorizationCodeFlow()
.AllowPasswordFlow()
.AllowRefreshTokenFlow();
options.RegisterScopes(OpenIdConnectConstants.Scopes.Email,
OpenIdConnectConstants.Scopes.Profile,
OpenIddictConstants.Scopes.Roles);
// This API was removed as client identification is now
// required by default. You can remove or comment this line.
//
// options.RequireClientIdentification();
options.EnableRequestCaching();
// This API was removed as scope validation is now enforced
// by default. You can safely remove or comment this line.
//
// options.EnableScopeValidation();
options.DisableHttpsRequirement();
});
我在离开项目很长时间(可能超过一年)后才回到项目,在将 VS2017 更新到版本 15.7.5 后,我在尝试重建项目时遇到了很多问题。第一个问题是 nuget 依赖项抱怨 OpenIddict 程序集“1.0.0.-*”被请求但收到“1.0.0-rtm-1063”。这些错误对我来说毫无意义,但我修改了我的 .csproj 文件,如下所示:
<!-- OpenIdDict -->
<!-- 1.0.0.-* changed to 1.0.0.-rtm-1063 -->
<PackageReference Include="AspNet.Security.OAuth.Validation" Version="1.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.1" />
<PackageReference Include="OpenIddict" Version="1.0.0-rtm-1063" />
<PackageReference Include="OpenIddict.EntityFrameworkCore" Version="1.0.0-rtm-1063" />
<PackageReference Include="OpenIddict.Mvc" Version="1.0.0-rtm-1063" />
这显然不是一个好的永久解决方案(什么是正确的解决方案?)加上这导致了一系列其他问题,这些问题通过替换
得到解决using OpenIddict.Models;
和
using OpenIddict.EntityFrameworkCore.Models;
这给我留下了两个我找不到解决方案的问题。
services.AddOpenIddict().AddEntityFrameworkCoreStores<ApplicationDbContext>()
未定义。
Configure()方法中对app.UseOpenIddict()的调用;抱怨 UseOpenIddict 未定义。
如果有人能为我指明解决这些问题的正确方向,我将不胜感激。
此外,该项目使用的是 .NET Core 1.1,据我所知,它已被 .NET Core 2.1 取代。我不清楚如何升级项目以使用 .NET Core 2.1。 VS2017 GUI 中的下拉列表仅包含 1.0 和 1.1 以及 "Install Other Frameworks..." 但是即使安装了最新的 2.1 SDK 和运行时,下拉列表中仍然没有 .NET Core 2.1 的选项。我做错了什么?
您应该删除 <PackageReference Include="AspNet.Security.OAuth.Validation" Version="1.0.0" />
,因为它现在被 OpenIddict
元包传递引用。
在 RC3 中,语法发生了一些变化,因此 services.AddOpenIddict().AddEntityFrameworkCoreStores<ApplicationDbContext>()
现在不再有效:
// In OpenIddict RC2, all the options used to be grouped.
services.AddOpenIddict(options =>
{
options.AddEntityFrameworkCoreStores<ApplicationDbContext>();
options.AddMvcBinders();
options.EnableAuthorizationEndpoint("/connect/authorize")
.EnableLogoutEndpoint("/connect/logout")
.EnableTokenEndpoint("/connect/token")
.EnableUserinfoEndpoint("/api/userinfo");
options.AllowAuthorizationCodeFlow()
.AllowPasswordFlow()
.AllowRefreshTokenFlow();
options.RegisterScopes(OpenIdConnectConstants.Scopes.Email,
OpenIdConnectConstants.Scopes.Profile,
OpenIddictConstants.Scopes.Roles);
options.RequireClientIdentification();
options.EnableRequestCaching();
options.EnableScopeValidation();
options.DisableHttpsRequirement();
});
// In OpenIddict RC3, the options are now split into 3 categories:
// the core services, the server services and the validation services.
services.AddOpenIddict()
.AddCore(options =>
{
// AddEntityFrameworkCoreStores() is now UseEntityFrameworkCore().
options.UseEntityFrameworkCore()
.UseDbContext<ApplicationDbContext>();
})
.AddServer(options =>
{
// AddMvcBinders() is now UseMvc().
options.UseMvc();
options.EnableAuthorizationEndpoint("/connect/authorize")
.EnableLogoutEndpoint("/connect/logout")
.EnableTokenEndpoint("/connect/token")
.EnableUserinfoEndpoint("/api/userinfo");
options.AllowAuthorizationCodeFlow()
.AllowPasswordFlow()
.AllowRefreshTokenFlow();
options.RegisterScopes(OpenIdConnectConstants.Scopes.Email,
OpenIdConnectConstants.Scopes.Profile,
OpenIddictConstants.Scopes.Roles);
// This API was removed as client identification is now
// required by default. You can remove or comment this line.
//
// options.RequireClientIdentification();
options.EnableRequestCaching();
// This API was removed as scope validation is now enforced
// by default. You can safely remove or comment this line.
//
// options.EnableScopeValidation();
options.DisableHttpsRequirement();
});