Migrating from IdentityServer4.AspNetIdentity 3.x to 4.x

Mahmood

When I was about to update the IdentityServer project in my solution, I ran into some issues.

In Login method:

IdentityServer/Quickstart/Account/AccountController.cs

  • ConsentResponse doesn’t contain a definition for Denied.
await _interaction.GrantConsentAsync(context, ConsentResponse.Denied);
  • IClientStore doesn’t contain definition for IsPkceClientAsync.
if (await _clientStore.IsPkceClientAsync(context.ClientId))

In BuildLoginViewModelAsync Method:

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();
  • AuthorizationRequest doesn’t contain definition for ClientId
var client = await _clientStore.FindEnabledClientByIdAsync(context.ClientId);

In Callback method:

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);
  • No overload method "SignInAsync" takes 5 arguments.
await HttpContext.SignInAsync(user.Id, name, provider, localSignInProps, additionalLocalClaims.ToArray());
Mahmood

I did some research and came up with the following: You can change as follow:

In Login method: 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())

In BuildLoginViewModelAsync Method: 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);

In Callback method: 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);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

IdentityServer4 w/AspNetIdentity and Registration API Methods

IdentityServer4 Usermanagement with separate MVC Client (AspNetIdentity)

How to validate x509 signing credentials with IdentityServer4

IdentityServer4 and ASP.NETCore 1.x

Migrating Angular 4.x to Angular 5

Migrating from Hibernate 4.X to 6.X Projections deprecated

IdentityServer4 IdentityServer3.AccessTokenValidation

Identityserver 4 Combined_AspNetIdentity_and_EntityFrameworkStorage

Migrating from swift 3 to swift 4

Where is placed createSwitchNavigator in react-navigation 5.x for migrating from react-navigation 4 to 5.x

Migrating from Joomla 2.5 to 3x Generating Errors

Migrating to bloc 8.0.1 from 3.x, getting depreciated errors

IdentityServer4 upgrade from v3 to v4 - scope validation error

IdentityServer4 (v3.1.x) Entity Framework - Session not persistent

How Can I remove the X-Frame-Options header in IdentityServer4?

IdentityServer4 - missing claims from Google

Unable to obtain configuration from IdentityServer4

Reusing IdentityServer3 refresh tokens in IdentityServer4

Problems migrating Node.js Azure Function from Function Extensions 2.x to 3.x

How to fix the webpage problem with IdentityServer4.AspNetIdentity

Is there a way to calculate 3D rotation on X and Y axis from a 4x4 matrix

Migrating generic function from Alamofire 3 to Alamofire 4

clear cache on current users' device in migrating from webpack 3 to 4

Lost automatic ActiveRecord caching by migrating from Rails 3 to Rails 4

Migrating issues from Gradle 3 to 4 in Android Studio 3.1

Facing problem while migrating API from mule 3 to mule 4

Migrating Grails 2.X to 3.X - What are Profiles?

How to migrate gulp.watch from gulp 3.x to gulp 4.x

Trying to Create 3x3x3 Cube but created 4x4x4 instead in OpenGL

TOP Ranking

HotTag

Archive