Hi
You can inject AbpApplicationManager to update application/client entity.
https://abp.io/docs/latest/modules/openiddict#database-providers
hi
Add BankIdOpenIddictServerHandler to your AuthServer project
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<OpenIddictServerBuilder>(builder =>
{
builder.AddEventHandler(BankIdOpenIddictServerHandler.Descriptor);
});
}
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Identity;
using OpenIddict.Abstractions;
using OpenIddict.Server;
namespace BankIdDemo;
public class BankIdOpenIddictServerHandler : IOpenIddictServerHandler<OpenIddictServerEvents.ProcessSignInContext>
{
public static OpenIddictServerHandlerDescriptor Descriptor { get; }
= OpenIddictServerHandlerDescriptor.CreateBuilder<OpenIddictServerEvents.ProcessSignInContext>()
.UseSingletonHandler<BankIdOpenIddictServerHandler>()
.SetOrder(100_000)
.SetType(OpenIddictServerHandlerType.Custom)
.Build();
public async ValueTask HandleAsync(OpenIddictServerEvents.ProcessSignInContext context)
{
if (context is { EndpointType: OpenIddictServerEndpointType.Authorization, AuthorizationCodePrincipal: not null})
{
var httpContext = context.Transaction.GetHttpRequest()?.HttpContext;
if (httpContext == null)
{
return;
}
var identity = await httpContext.AuthenticateAsync(IdentityConstants.ApplicationScheme);
if (identity?.Principal == null)
{
return;
}
var nationalidentitynumber =identity?.Principal?.FindFirst("nationalidentitynumber")?.Value;
if (!nationalidentitynumber.IsNullOrWhiteSpace())
{
context.AuthorizationCodePrincipal?.AddClaim("nationalidentitynumber", nationalidentitynumber);
}
return;
}
if (context is { EndpointType: OpenIddictServerEndpointType.Token, AccessTokenPrincipal: not null})
{
var nationalidentitynumber = context.AccessTokenPrincipal?.FindFirst("nationalidentitynumber")?.Value;
if (!nationalidentitynumber.IsNullOrWhiteSpace())
{
context.AccessTokenPrincipal?.AddClaim("nationalidentitynumber", nationalidentitynumber);
}
}
}
}
Great π
hi
Add the code below to fix the ReturnUrl issue. I will fix it in the next version
Thanks
Configure<AbpAccountOptions>(options =>
{
options.GetTenantDomain = (httpContext, tenantInfo) =>
{
var returnUrl = "";
if (httpContext.Request.HasFormContentType)
{
var form = httpContext.Request.Form;
if (form.ContainsKey("ReturnUrl"))
{
returnUrl = form["ReturnUrl"];
}
}
return Task.FromResult(httpContext.Request.Scheme + "://" + httpContext.Request.Host + httpContext.Request.PathBase + returnUrl);
};
});
Please create an Angular template project and share it with liming.ma@volosoft.com
Thanks.
hi
I will test your case with GitHub login.
Is that ok for you?
You can create an Angular template project and share it with liming.ma@volosoft.com
Thanks.
hi
You can call the await InvokeAsync(StateHasChanged) after changing the SelectedTenantId. Ensure the input has set the correct value.
hi
If you don't need to use HandleSelector, then you don't need to yograde packages.
Processed will be true.Processed will be true.Processed will be false.hi
I can create a demo project, but I don't have an external user account with extra claims.
Thatβs why I ask you to share a project and test BankID user info.
Thanks.
hi
I hard-coded the tenant ID and tested in a Blazor Server project. And it works
see video: https://streamable.com/ydbb20
raw video: https://we.tl/t-YZoGwV7p6C