- ABP Framework version: v5.1.4
- UI type: Blazor
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): no Abp provide a good way to configure dynamic optons for OAuth login. I can configure the valu for every tenant. And it is working. Every tenant can use it's own value while OAuth remote login.
context.Services.AddAuthentication()
.AddGoogle(GoogleDefaults.AuthenticationScheme, _ => { })
.WithDynamicOptions<GoogleOptions, GoogleHandler>(
GoogleDefaults.AuthenticationScheme,
options =>
{
options.WithProperty(x => x.ClientId);
options.WithProperty(x => x.ClientSecret, isSecret: true);
}
)
My question is How to get the danymic option manually? I wan't to use it in Volo.Abp.Account.Pro.Publick.Web.Pages.Accounts.Login.cshtml.cs I must use the values of the danymicoption in below stage.
[UnitOfWork]
public virtual async Task<IActionResult> OnGetExternalLoginCallbackAsync(string returnUrl = "", string returnUrlHash = "", string remoteError = null)
3 Answer(s)
-
0
Oh, may I use as below?
string providers= await this.SettingProvider.GetOrNullAsync("Abp.Account.ExternalProviders");
-
0
I wrote my functions to read the value I need. I am testing and waiting answers from you.
namespace Yee.Change.Common.WebShared.IdentityServers { using System; using System.Linq; using System.Text; using Newtonsoft.Json; using Volo.Abp.Settings; using System.Threading.Tasks; using System.Collections.Generic; public class SettingUtils { public async Task<string> GetSetting(ISettingProvider settingProvider, string externalProviderSchema, string name) { string json = await settingProvider.GetOrNullAsync("Abp.Account.ExternalProviders"); if (string.IsNullOrWhiteSpace(json)) { throw new Exception("json is null"); } List<ExternalProviderSettings> providers = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ExternalProviderSettings>>(json); ExternalProviderSettings externalProvider = providers.FirstOrDefault(p => p.Name == externalProviderSchema); PropertityInfo properti = externalProvider.Propertities.First(p => p.Name == name); if (properti != null) { return properti.Value; } return string.Empty; } } public class ExternalProviderSettings { [JsonProperty("name")] public string Name { get; set; } [JsonProperty("enabled")] public bool Enabled { get; set; } [JsonProperty("properties")] public List<PropertityInfo> Propertities { get; set; } [JsonProperty("secretProperties")] public List<PropertityInfo> SecretPropertities { get; set; } } public class PropertityInfo { [JsonProperty("name")] public string Name { get; set; } [JsonProperty("value")] public string Value { get; set; } } }
-
0
Options( the options pattern ) and Setting(Configuration system) are both derived from .net core (extensions) and more powerful
Settings providers read configuration data from key-value pairs using a variety of configuration sources
Options uses classes to provide strongly typed access to groups of related settings. is used to configure a group of settings used by the framework services.
you may define
Settings
, or derives something from AbpDynamicOptionsManagerfollow the documents: https://docs.abp.io/en/abp/latest/Settings https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-6.0
https://docs.abp.io/en/abp/latest/Options https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-6.0