Hi ! I applied this piece of code, but the issue still remained unsolved.
Could you copy the code of Microsoft.AspNetCore.Authentication.MicrosoftAccount
?
The ClientSecret obtained in the code is encrypted content.
[Dependency(ReplaceServices = true)] [ExposeServices(typeof(ExternalProviderSettingsHelper))] public class MyExternalProviderSettingsHelper : ExternalProviderSettingsHelper { private readonly ISettingDefinitionManager _settingDefinitionManager; private readonly ISettingEncryptionService _settingEncryptionService; private readonly ICurrentTenant _currentTenant; private readonly AbpExternalProviderOptions _externalProviderOptions; private readonly ISettingManager _settingManager; private readonly IJsonSerializer _jsonSerializer; public MyExternalProviderSettingsHelper( ICurrentTenant currentTenant, IOptions<AbpExternalProviderOptions> externalProvidersOptions, ISettingManager settingManager, IJsonSerializer jsonSerializer, IStringEncryptionService stringEncryptionService, ISettingDefinitionManager settingDefinitionManager, ISettingEncryptionService settingEncryptionService) : base(currentTenant, externalProvidersOptions, settingManager, jsonSerializer, stringEncryptionService) { _settingDefinitionManager = settingDefinitionManager; _settingEncryptionService = settingEncryptionService; _currentTenant = currentTenant; _externalProviderOptions = externalProvidersOptions.Value; _settingManager = settingManager; _jsonSerializer = jsonSerializer; }
Using your approach will result in the clientSecret configured by tenant in the setting being ineffective.
Ok. How to solve the problem of failed login from External provider now? The Client secrets obtained by my provider are encrypted.
Why is it necessary to encrypt the Client secret? This leads to a very serious disaster in the update of the Release environment, and this is not mentioned in the migration instructions.
Angular environment that can be reproduced
const oAuthConfig = {
issuer: 'http://localhost:44372/',
redirectUri: baseUrl,
clientId: 'BookStore_App',
responseType: 'password', // change to password
scope: 'offline_access BookStore',
requireHttps: false,
impersonation: {
userImpersonation: true,
tenantImpersonation: true,
},
};
I seem to have spotted the issue
I create this via
abp new Acme.Demo-u angular
Angular templates do not appear to have external login associations
Hi
Which version to use?
I used when 9.0.0 to create an empty template, but no Account External Provider
The template has confirmed that SSO is enabled
context.Services.AddAuthentication()
.AddGoogle(GoogleDefaults.AuthenticationScheme, options =>
{
options.ClaimActions.MapJsonKey(AbpClaimTypes.Picture, "picture");
})
.WithDynamicOptions<GoogleOptions, GoogleHandler>(
GoogleDefaults.AuthenticationScheme,
options =>
{
options.WithProperty(x => x.ClientId);
options.WithProperty(x => x.ClientSecret, isSecret: true);
}
)
.AddMicrosoftAccount(MicrosoftAccountDefaults.AuthenticationScheme, options =>
{
//Personal Microsoft accounts as an example.
options.AuthorizationEndpoint = "https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize";
options.TokenEndpoint = "https://login.microsoftonline.com/consumers/oauth2/v2.0/token";
options.ClaimActions.MapCustomJson("picture", _ => "https://graph.microsoft.com/v1.0/me/photo/$value");
options.SaveTokens = true;
})
.WithDynamicOptions<MicrosoftAccountOptions, MicrosoftAccountHandler>(
MicrosoftAccountDefaults.AuthenticationScheme,
options =>
{
////options.WithProperty(x => x.ClientId);
options.WithProperty(x => x.ClientSecret, isSecret: true);
}
)
.AddTwitter(TwitterDefaults.AuthenticationScheme, options =>
{
options.ClaimActions.MapJsonKey(AbpClaimTypes.Picture, "profile_image_url_https");
options.RetrieveUserDetails = true;
})
.WithDynamicOptions<TwitterOptions, TwitterHandler>(
TwitterDefaults.AuthenticationScheme,
options =>
{
options.WithProperty(x => x.ConsumerKey);
options.WithProperty(x => x.ConsumerSecret, isSecret: true);
}
);