Hi
i found that Microsoft.Identity.Web doesn't work with await SignInManager.GetExternalLoginInfoAsync();
so that's why you are not able to proceed with login.
I tried with <PackageReference Include="Microsoft.Graph" Version="5.25.0" />
i am able get GraphServiceClient
working
by creating a IAccessTokenProvider
implementation
creaate a IntegratedAbpioTokenProvider
like below in authservermodule
using Microsoft.AspNetCore.Identity;
using Microsoft.Kiota.Abstractions.Authentication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Acme.BookStore
{
public class IntegratedAbpioTokenProvider : IAccessTokenProvider
{
public IntegratedAbpioTokenProvider(SignInManager< Volo.Abp.Identity.IdentityUser > signInManager)
{
SignInManager = signInManager ?? throw new Exception();
}
public SignInManager< Volo.Abp.Identity.IdentityUser > SignInManager { get; set; }
public AllowedHostsValidator AllowedHostsValidator { get; }
public async Task< string > GetAuthorizationTokenAsync(Uri uri, Dictionary<string, object>? additionalAuthenticationContext = null, CancellationToken cancellationToken = default)
{
var token = await SignInManager.GetExternalLoginInfoAsync();
var accessToken = token?.AuthenticationTokens?.FirstOrDefault(x => x.Name == "access_token");
return accessToken?.Value ?? string.Empty;
}
}
}
and you can initialize GraphServiceClient
like this
if you still want to go with identity web please follow this github example
https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/tree/master/2-WebApp-graph-user/2-1-Call-MSGraph
you just have to add following code
context.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(configuration.GetSection("AzureAd"), displayName: "Webapp")
.EnableTokenAcquisitionToCallDownstreamApi(initialScopes)
.AddMicrosoftGraph(configuration.GetSection("DownstreamApi"))
.AddInMemoryTokenCaches();
but after doing that you have to create a user inside OnGetExternalLoginCallbackAsync
please see the full implementation of OnGetExternalLoginCallbackAsync
https://github.com/abpframework/abp/blob/3fb86d658981748289ba8b6d5c59e857bc8c9e18/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs#L175 which you have to modify it based on Microsoft.Identity.Web
results.
SigninManager docs on microsoft https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.identity.signinmanager-1.getexternallogininfoasync?view=aspnetcore-7.0
Hello sanobarm@cloudassert.com,
Please do let us know if this solution has worked for you?
Awaiting for your response.
Thank You, Anjali
Hello nanohealthserviceaccount,
Please do let us know if this solution has worked for you?
Awaiting for your response.
Thank You, Anjali
Hello bkrm.dev01,
Please do let us know if we can help you with something else?
Thank You, Anjali
Hello aksogut,
Hope you doing well.
Can we close this ticket if your query is resolved? Please confirm.
Awaiting for your valuable response.
Thank You, Anjali
Hi
I have made the changes
Please replace previous code for AppBsonSerializationProvider
class with following code, i have tested it on menu item, edit is now working
public class AppBsonSerializationProvider : IBsonSerializationProvider
{
public IBsonSerializer GetSerializer(Type type)
{
Console.WriteLine(type?.FullName);
if ((type?.GetProperty(nameof(AggregateRoot.ExtraProperties)) != null) && type?.GetConstructor(Type.EmptyTypes) == null)
{
Type serializerType = typeof(AppBsonClassMapSerializer<>).MakeGenericType(type);
return (IBsonSerializer)Activator.CreateInstance(serializerType, BsonClassMap.LookupClassMap(type));
}
return null;
}
}
This is issue has been logged please check here https://github.com/abpframework/abp/issues/17521 you can remove the above code when you have upgraded abp 7.4 and test
Hi
2FA is provided by abp commercial you just need tp enable it from the account settings https://docs.abp.io/en/commercial/latest/modules/identity/two-factor-authentication
if you want to enable 2FA with Google Authenticator please see here https://docs.microsoft.com/en-us/aspnet/core/security/authentication/mfa?view=aspnetcore-6.0
Hello alexander.nikonov ,
Can you please try to add this code
import { SubscriptionService } from '@abp/ng.core';
constructor(private subscriptionService: SubscriptionService)
this.subscriptionService.closeAll() // add this line in logout event
Please let me know if this helps you or you may provide some steps to reproduce the issue as I am unable to reproduce it.
Thank you, Anjali
Hi @Sergei.Gorlovetsky,
Please replace previous code for AppBsonSerializationProvider
class with following code, i have tested it on your project, edit is now working
public class AppBsonSerializationProvider : IBsonSerializationProvider
{
public IBsonSerializer GetSerializer(Type type)
{
if ((type?.BaseType?.FullName.Contains(typeof(Volo.Abp.Domain.Entities.Auditing.FullAuditedAggregateRoot)?.FullName)).GetValueOrDefault())
{
Type serializerType = typeof(AppBsonClassMapSerializer<>).MakeGenericType(type);
return (IBsonSerializer)Activator.CreateInstance(serializerType, BsonClassMap.LookupClassMap(type));
}
return null;
}
}
Hi
can you try replacing
if (moduleIdPolicyViolated && ordinaryRolePolicyViolated) {
permissionProhibitedPageIds.push(nonLazyRouteItem.name);
}
else {
nonLazyRouteItem.invisible = false;
}
with below code
if (!(moduleIdPolicyViolated && ordinaryRolePolicyViolated)) {
nonLazyRouteItem.invisible = false;
}
and remove the
this.routesService.remove(permissionProhibitedPageIds);