从 IdentityServer4.AspNetIdentity 3.x 迁移到 4.x
Migrating from IdentityServer4.AspNetIdentity 3.x to 4.x
当我要在我的解决方案中更新 IdentityServer 项目时,我 运行 遇到了一些问题。
登录方式:
IdentityServer/Quickstart/Account/AccountController.cs
- ConsentResponse 不包含拒绝的定义。
await _interaction.GrantConsentAsync(context, ConsentResponse.Denied);
- IClientStore 不包含 IsPkceClientAsync 的定义。
if (await _clientStore.IsPkceClientAsync(context.ClientId))
在 BuildLoginViewModelAsync 方法中:
IdentityServer/Quickstart/Account/AccountController.cs
- AccountOptions 不包含 WindowsAuthenticationSchemeName 的定义
var providers = schemes
.Where(x => x.DisplayName != null ||
(x.Name.Equals(AccountOptions.WindowsAuthenticationSchemeName, StringComparison.OrdinalIgnoreCase))
)
.Select(x => new ExternalProvider
{
DisplayName = x.DisplayName,
AuthenticationScheme = x.Name
}).ToList();
- AuthorizationRequest 不包含 ClientId 的定义
var client = await _clientStore.FindEnabledClientByIdAsync(context.ClientId);
在回调方法中:
IdentityServer/Quickstart/Account/ExternalController.cs
- 当前上下文中不存在名称“ProcessLoginCallbackForOidc”
ProcessLoginCallbackForOidc(result, additionalLocalClaims, localSignInProps);
ProcessLoginCallbackForWsFed(result, additionalLocalClaims, localSignInProps);
ProcessLoginCallbackForSaml2p(result, additionalLocalClaims, localSignInProps);
- 没有重载方法“SignInAsync”接受 5 个参数。
await HttpContext.SignInAsync(user.Id, name, provider, localSignInProps, additionalLocalClaims.ToArray());
我做了一些研究,得出以下结论:您可以按如下方式更改:
登录方式: IdentityServer/Quickstart/Account/AccountController.cs
ConsentResponse doesn’t contain a definition for Denied.
await _interaction.GrantConsentAsync(context, ConsentResponse.Denied);
Change to:
await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied);
IClientStore doesn’t contain definition for IsPkceClientAsync.
if (await _clientStore.IsPkceClientAsync(context.ClientId))
Change to:
if (context.IsNativeClient())
在 BuildLoginViewModelAsync 方法中: IdentityServer/Quickstart/Account/AccountController.cs
AccountOptions doesn’t contain definition for WindowsAuthenticationSchemeName
var providers = schemes
.Where(x => x.DisplayName != null ||
(x.Name.Equals(AccountOptions.WindowsAuthenticationSchemeName, StringComparison.OrdinalIgnoreCase))
)
.Select(x => new ExternalProvider
{
DisplayName = x.DisplayName,
AuthenticationScheme = x.Name
}).ToList();
Change to:
var providers = schemes
.Where(x => x.DisplayName != null)
.Select(x => new ExternalProvider
{
DisplayName = x.DisplayName ?? x.Name,
AuthenticationScheme = x.Name
}).ToList();
AuthorizationRequest doesn’t contain definition for ClientId
var client = await _clientStore.FindEnabledClientByIdAsync(context.ClientId);
Change to:
var client = await _clientStore.FindEnabledClientByIdAsync(context.Client.ClientId);
在回调方法中: IdentityServer/Quickstart/Account/ExternalController.cs
The name ‘ProcessLoginCallbackForOidc’ does not exist in the current context
ProcessLoginCallbackForOidc(result, additionalLocalClaims, localSignInProps);
ProcessLoginCallbackForWsFed(result, additionalLocalClaims, localSignInProps);
ProcessLoginCallbackForSaml2p(result, additionalLocalClaims, localSignInProps);
Change to:
ProcessLoginCallback(result, additionalLocalClaims, localSignInProps);
No overload method "SignInAsync" takes 5 arguments.
await HttpContext.SignInAsync(user.Id, name, provider, localSignInProps, additionalLocalClaims.ToArray());
Change to:
var isuser = new IdentityServerUser(user.Id)
{
DisplayName = name,
IdentityProvider = provider,
AdditionalClaims = additionalLocalClaims
};
await HttpContext.SignInAsync(isuser, localSignInProps);
当我要在我的解决方案中更新 IdentityServer 项目时,我 运行 遇到了一些问题。
登录方式:
IdentityServer/Quickstart/Account/AccountController.cs
- ConsentResponse 不包含拒绝的定义。
await _interaction.GrantConsentAsync(context, ConsentResponse.Denied);
- IClientStore 不包含 IsPkceClientAsync 的定义。
if (await _clientStore.IsPkceClientAsync(context.ClientId))
在 BuildLoginViewModelAsync 方法中:
IdentityServer/Quickstart/Account/AccountController.cs
- AccountOptions 不包含 WindowsAuthenticationSchemeName 的定义
var providers = schemes
.Where(x => x.DisplayName != null ||
(x.Name.Equals(AccountOptions.WindowsAuthenticationSchemeName, StringComparison.OrdinalIgnoreCase))
)
.Select(x => new ExternalProvider
{
DisplayName = x.DisplayName,
AuthenticationScheme = x.Name
}).ToList();
- AuthorizationRequest 不包含 ClientId 的定义
var client = await _clientStore.FindEnabledClientByIdAsync(context.ClientId);
在回调方法中:
IdentityServer/Quickstart/Account/ExternalController.cs
- 当前上下文中不存在名称“ProcessLoginCallbackForOidc”
ProcessLoginCallbackForOidc(result, additionalLocalClaims, localSignInProps);
ProcessLoginCallbackForWsFed(result, additionalLocalClaims, localSignInProps);
ProcessLoginCallbackForSaml2p(result, additionalLocalClaims, localSignInProps);
- 没有重载方法“SignInAsync”接受 5 个参数。
await HttpContext.SignInAsync(user.Id, name, provider, localSignInProps, additionalLocalClaims.ToArray());
我做了一些研究,得出以下结论:您可以按如下方式更改:
登录方式: IdentityServer/Quickstart/Account/AccountController.cs
ConsentResponse doesn’t contain a definition for Denied.
await _interaction.GrantConsentAsync(context, ConsentResponse.Denied);
Change to:
await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied);
IClientStore doesn’t contain definition for IsPkceClientAsync.
if (await _clientStore.IsPkceClientAsync(context.ClientId))
Change to:
if (context.IsNativeClient())
在 BuildLoginViewModelAsync 方法中: IdentityServer/Quickstart/Account/AccountController.cs
AccountOptions doesn’t contain definition for WindowsAuthenticationSchemeName
var providers = schemes
.Where(x => x.DisplayName != null ||
(x.Name.Equals(AccountOptions.WindowsAuthenticationSchemeName, StringComparison.OrdinalIgnoreCase))
)
.Select(x => new ExternalProvider
{
DisplayName = x.DisplayName,
AuthenticationScheme = x.Name
}).ToList();
Change to:
var providers = schemes
.Where(x => x.DisplayName != null)
.Select(x => new ExternalProvider
{
DisplayName = x.DisplayName ?? x.Name,
AuthenticationScheme = x.Name
}).ToList();
AuthorizationRequest doesn’t contain definition for ClientId
var client = await _clientStore.FindEnabledClientByIdAsync(context.ClientId);
Change to:
var client = await _clientStore.FindEnabledClientByIdAsync(context.Client.ClientId);
在回调方法中: IdentityServer/Quickstart/Account/ExternalController.cs
The name ‘ProcessLoginCallbackForOidc’ does not exist in the current context
ProcessLoginCallbackForOidc(result, additionalLocalClaims, localSignInProps);
ProcessLoginCallbackForWsFed(result, additionalLocalClaims, localSignInProps);
ProcessLoginCallbackForSaml2p(result, additionalLocalClaims, localSignInProps);
Change to:
ProcessLoginCallback(result, additionalLocalClaims, localSignInProps);
No overload method "SignInAsync" takes 5 arguments.
await HttpContext.SignInAsync(user.Id, name, provider, localSignInProps, additionalLocalClaims.ToArray());
Change to:
var isuser = new IdentityServerUser(user.Id)
{
DisplayName = name,
IdentityProvider = provider,
AdditionalClaims = additionalLocalClaims
};
await HttpContext.SignInAsync(isuser, localSignInProps);