Hi I have some predefined roles and seed them during migration. I want to add permissions to those roles during seed process. Docs recommend to define permission providers in Application.Contracts project, but PermissionDefenitionProvider are reflected while starting web project. I also moved them to Domain.Shared project, but not succeed. I will be glad if you give a good and standard solution for this scenario.
Thanks, This solved my problem What about edition features seed contributor? Do you have an example?
This is what I have done, but still getting default profile image
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IAccountAppService), typeof(AccountAppService),
typeof(MyAccountAppService))]
public class MyAccountAppService : AccountAppService
{
public RecruitansAccountAppService(
IdentityUserManager userManager,
IAccountEmailer accountEmailer,
IAccountPhoneService phoneService,
IIdentityRoleRepository roleRepository,
IdentitySecurityLogManager identitySecurityLogManager,
IBlobContainer accountProfilePictureContainer,
ISettingManager settingManager,
IOptions identityOptions,
IIdentitySecurityLogRepository securityLogRepository)
: base(userManager, accountEmailer, phoneService, roleRepository, identitySecurityLogManager,
accountProfilePictureContainer, settingManager, identityOptions, securityLogRepository)
{
}
public override async Task<IRemoteStreamContent> GetProfilePictureFileAsync(Guid id)
{
using (DataFilter.Disable<IMultiTenant>())
{
return await base.GetProfilePictureFileAsync(id);
}
}
}
Thanks This solved the problem
public override async Task<IRemoteStreamContent> GetProfilePictureFileAsync(Guid id)
{
Guid? targetTenantId = null;
using (DataFilter.Disable<IMultiTenant>())
{
var user = await UserRepository.FindAsync(id);
targetTenantId = user.TenantId;
}
using (CurrentTenant.Change(targetTenantId))
{
return await base.GetProfilePictureFileAsync(id);
}
}
Hi Trying to implement DomanTenantResolver sample in my own project, everything is fine, except I cant use swagger in *HttpiApi.Host. Redirection from Identity back to api does not work. Neither with tenant available nor without tenant(host). I also tried to add OnChallenge event to JwtBearerOptions during configuration, but no success. I have no idea how to implement this. P.S: In your sample resolver, I cant event authorize with "web.getap.com:1234/swagger". In other words, api is out of reach.
Any help would be appreciated
Hi there
First simple scenario:
"IdentityServer": {
"Clients": {
"BookStore_Web": {
"ClientId": "BookStore_Web",
"ClientSecret": "1q2w3e*",
"RootUrl": "https://{0}.web.getabp.net:44303"
},
"BookStore_Swagger": {
"ClientId": "BookStore_Swagger",
"ClientSecret": "1q2w3e*",
"RootUrl": "https://{0}.api.getabp.net:44302"
}
}
//Web Client
var webClientId = configurationSection["BookStore_Web:ClientId"];
if (!webClientId.IsNullOrWhiteSpace())
{
var webClientRootUrl = configurationSection["BookStore_Web:RootUrl"].EnsureEndsWith('/');
/* BookStore_Web client is only needed if you created a tiered
* solution. Otherwise, you can delete this client. */
await CreateClientAsync(
name: webClientId,
scopes: commonScopes,
grantTypes: new[] { "hybrid" },
secret: (configurationSection["BookStore_Web:ClientSecret"] ?? "1q2w3e*").Sha256(),
redirectUri: $"{webClientRootUrl}signin-oidc",
postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc",
frontChannelLogoutUri: $"{webClientRootUrl}Account/FrontChannelLogout",
corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") }
);
}
// Swagger Client
var swaggerClientId = configurationSection["BookStore_Swagger:ClientId"];
if (!swaggerClientId.IsNullOrWhiteSpace())
{
var swaggerRootUrl = configurationSection["BookStore_Swagger:RootUrl"].TrimEnd('/');
await CreateClientAsync(
name: swaggerClientId,
scopes: commonScopes,
grantTypes: new[] { "authorization_code" },
secret: (configurationSection["Recruitans_Swagger:ClientSecret"] ?? "1q2w3e*").Sha256(),
requireClientSecret: false,
redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html",
corsOrigins: new[] { swaggerRootUrl.RemovePostFix("/") }
);
}
This is the initial scenario that I cant use swagger api.
Actually this worked for me
"https://*.api.getabp.net,https://*.web.getabp.net,https://api.getabp.net:44302"
This is solution for host user authorization.
Now, the second part. How should we handle https://tenant1.api.getabp.net:44302/swagger/index.html for tenant1?
I want to implement resolver for web api project:
Configure<AbpTenantResolveOptions>(options =>
{
options.AddDomainTenantResolver("{0}.api.getabp.net:44302");
});
Then, I want to go to https://tenant1.api.getabp.net:44302/swagger/index.html When authorizing, I want to be automatically be directed to https://tenant.ids.getabp.net:44301 After that, redirect back to https://tenant1.api.getabp.net:44302/swagger/index.html Now, my swagger client is authorized and the active tenant is tenant1 Hence, current tenant id will tenant1 id. Just like web project.
Hope you understand
Thanks a lot This solved the problem Better to update sample to avoid future duplicate questions
Hi I tried to override some methods in AbpApplicationConfigurationAppService class as follow:
public class CustomApplicationConfigurationAppService :
AbpApplicationConfigurationAppService
{
public CustomApplicationConfigurationAppService(
IOptions<AbpLocalizationOptions> localizationOptions,
IOptions<AbpMultiTenancyOptions> multiTenancyOptions,
IServiceProvider serviceProvider,
IAbpAuthorizationPolicyProvider abpAuthorizationPolicyProvider,
IPermissionDefinitionManager permissionDefinitionManager,
DefaultAuthorizationPolicyProvider defaultAuthorizationPolicyProvider,
IPermissionChecker permissionChecker,
IAuthorizationService authorizationService,
ICurrentUser currentUser,
ISettingProvider settingProvider,
ISettingDefinitionManager settingDefinitionManager,
IFeatureDefinitionManager featureDefinitionManager,
ILanguageProvider languageProvider,
ITimezoneProvider timezoneProvider,
IOptions<AbpClockOptions> abpClockOptions,
ICachedObjectExtensionsDtoService cachedObjectExtensionsDtoService)
: base(localizationOptions, multiTenancyOptions, serviceProvider, abpAuthorizationPolicyProvider,
permissionDefinitionManager, defaultAuthorizationPolicyProvider, permissionChecker,
authorizationService,
currentUser, settingProvider, settingDefinitionManager, featureDefinitionManager, languageProvider,
timezoneProvider, abpClockOptions, cachedObjectExtensionsDtoService)
{
}
protected override async Task<ApplicationLocalizationConfigurationDto> GetLocalizationConfigAsync()
{
var localizationConfig = new ApplicationLocalizationConfigurationDto();
return localizationConfig;
}
}
Add replaced using traditional style in my ApplicationModule.cs : context.Services.Replace(ServiceDescriptor.Transient<IAbpApplicationConfigurationAppService, CustomApplicationConfigurationAppService>());
when I GET /api/abp/application-configuration from swagger, the result is as expected and localization is empty: but when launching web project, the response from GET request to /Abp/ApplicationConfigurationScript contains all localization data:
Why is this happening? And what is the solution?