Starts in:
2 DAYS
10 HRS
51 MIN
9 SEC
Starts in:
2 D
10 H
51 M
9 S

Activities of "otee@urvin.finance"

I created an IExtensionGrantValidator using the code below. I want the code to be hit **ValidateAsync ** when i request a token using the grant type named delegation.

public class DelegationGrantValidator : IExtensionGrantValidator
    {
        private readonly UserManager<IdentityUser> _userManager;

        public string GrantType => "delegation";

        public DelegationGrantValidator(UserManager<IdentityUser> userManager)
        {
            _userManager = userManager;
        }
        
        public async Task ValidateAsync(ExtensionGrantValidationContext context)
        {
            var userId = context.Request.Raw.Get("user_id");

            var user = await _userManager.FindByIdAsync(userId);

            if (user == null)
            {
                context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant);
                return;
            }
            else
            {
                var userClaims = await _userManager.GetClaimsAsync(user);
                var claimsIdentity = new ClaimsIdentity(userClaims);
                var claimsPrincipal = new ClaimsPrincipal(claimsIdentity);
                context.Result = new GrantValidationResult(claimsPrincipal);

                return;
            }
        }
    }

I registered the grant as below:

public override void PostConfigureServices(ServiceConfigurationContext context)
    {
        var hostingEnvironment = context.Services.GetHostingEnvironment();
        
        context.Services.Configure<IIdentityServerBuilder>(builder =>
        {
            builder.AddExtensionGrantValidator<DelegationGrantValidator>();
        });
    }

I get an error when i call the token endpoint on AuthServer as below using :

2022-03-14 13:53:45.997 +01:00 [ERR] No validator is registered for the grant type{"grantType":"delegation"}, details: {"ClientId":"UrvinFinance_BlazorServer","ClientName":"UrvinFinance_BlazorServer","GrantType":"delegation","Scopes":null,"AuthorizationCode":"********","RefreshToken":"********","UserName":null,"AuthenticationContextReferenceClasses":null,"Tenant":null,"IdP":null,"Raw":{"grant_type":"delegation","username":"admin","token":"1q2w3E*","client_id":"UrvinFinance_BlazorServer","client_secret":"***REDACTED***"},"$type":"TokenRequestValidationLog"}
2022-03-14 13:53:46.009 +01:00 [INF] {"ClientId":"UrvinFinance_BlazorServer","ClientName":"UrvinFinance_BlazorServer","RedirectUri":null,"Endpoint":"Token","SubjectId":null,"Scopes":null,"GrantType":"delegation","Error":"unsupported_grant_type","ErrorDescription":null,"Category":"Token","Name":"Token Issued Failure","EventType":"Failure","Id":2001,"Message":null,"ActivityId":"0HMG5N6KTSCAB:00000002","TimeStamp":"2022-03-14T12:53:46.0000000Z","ProcessId":35236,"LocalIpAddress":"::1:44322","RemoteIpAddress":"::1","$type":"TokenIssuedFailureEvent"}

Note: I've registered the granttype for on the client. I also tried configuring in ConfigureService and PreConfigureService of AuthServer.

I also removed my code and followed the documentation on identity server. https://identityserver4.readthedocs.io/en/aspnetcore2/topics/extension_grants.html#refextensiongrants I got same error.

I've added two columns to my IdentityUser table on their separate columns. The columns are Title and Nickname,

How do i search IdentityUser table by the extended field named Nickname to return the user?

Regards, Otee

Thanks it's working now. I updated Volo.Abp.Identity.Pro.Application.Contracts with this version you specified for it to work.

I've looked and confirmed all my packages are pointing to the downloaded source code.

The dll generated is version 1.0.0.0 because i downloaded the source code of Account & Identity. But for some reason the application is looking for 5.1.3.0.

I had to add binding redirect on the blazor server app web.config as below.

&lt;runtime&gt;
	&lt;assemblyBinding xmlns=&quot;urn:schemas-microsoft-com:asm.v1&quot;&gt;
		&lt;dependentAssembly&gt;
			&lt;assemblyIdentity name=&quot;Volo.Abp.Identity.Pro.Application.Contracts&quot; culture=&quot;neutral&quot; publicKeyToken=&quot;null&quot;/&gt;
			&lt;bindingRedirect oldVersion=&quot;5.1.3.0&quot; newVersion=&quot;1.0.0.0&quot;/&gt;
		&lt;/dependentAssembly&gt;
	&lt;/assemblyBinding&gt;
&lt;/runtime&gt;

But still got same error.

[blazor_d19aee54-b]: System.IO.FileLoadException: Could not load file or assembly 'Volo.Abp.Identity.Pro.Application.Contracts, Version=5.1.3.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (0x80131040) [blazor_d19aee54-b]: File name: 'Volo.Abp.Identity.Pro.Application.Contracts, Version=5.1.3.0, Culture=neutral, PublicKeyToken=null'

All other apps work as they should but the blazor server app doesn't work.

I've seen suggestions that says i should download some other project because something else might be referencing version 5.1.3.0. I don't even know which project is affecting so i don't know which project to download.

Showing 11 to 14 of 14 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06