Add to app.UseSwagger();
before
Hi,
You can add a middleware to do it: like this:
if (!env.IsDevelopment())
{
app.Use(async (httpContext, next) =>
{
if (httpContext.Request.Path.Value.ToLower().Contains("swagger"))
{
var user = httpContext.RequestServices.GetService<ICurrentUser>();
if (user.IsAuthenticated && user.IsInRole("Admin"))
{
httpContext.Response.StatusCode = 404;
return;
}
}
await next.Invoke();
});
}
Hi,
You need to enable multi-tenancy and install the saas module.
Hi,
You can refer the audit-loggin module.
Hi,
Please see: https://github.com/abpframework/abp/issues/4388, https://github.com/abpframework/abp/issues/4350. They can help you.
Hi,
if it is a simple service and not use database,you can just create libary project , like volo.abp.automapper
.
Hi,
Example (c# client):
var client = new HttpClient();
var disco = await client.GetDiscoveryDocumentAsync(_configuration["IdentityClients:Default:Authority"]);
if (disco.IsError)
{
Console.WriteLine(disco.Error);
return;
}
// request token
var tokenResponse = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest()
{
Address = disco.TokenEndpoint,
ClientId = _configuration["IdentityClients:Default:ClientId"],
ClientSecret = _configuration["IdentityClients:Default:ClientSecret"],
Scope = _configuration["IdentityClients:Default:Scope"]
});
using (var httpClient = new HttpClient())
{
httpClient.SetBearerToken(tokenResponse.AccessToken);
var url = _configuration["RemoteServices:MyProjectName:BaseUrl"] +
"api/MyProjectName/sample/authorized";
var responseMessage = await httpClient.GetAsync(url);
if (responseMessage.IsSuccessStatusCode)
{
var responseString = await responseMessage.Content.ReadAsStringAsync();
Console.WriteLine("Result: " + responseString);
}
else
{
throw new Exception("Remote server returns error code: " + responseMessage.StatusCode);
}
}
Hi,
Are you logged in to the application? Can you share the request message? thanks.
Hi,
You don't need do this, because abp has completed the configuration.
See https://github.com/abpframework/abp/issues/1414#issuecomment-508818941.
If you still want add navigation properties, please do this:
Entity:
public class UnitCategory : Entity<Guid>
{
public UnitCategory(Guid id)
{
Id = id;
}
public List<OrganizationUnit> OrganizationUnits { get; set; }
}
DbContext:
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
/* Configure the shared tables (with included modules) here */
builder.Entity<AppUser>(b =>
{
b.ToTable(AbpIdentityDbProperties.DbTablePrefix +
"Users"); //Sharing the same table "AbpUsers" with the IdentityUser
b.ConfigureByConvention();
b.ConfigureAbpUser();
/* Configure mappings for your additional properties
* Also see the qaEfCoreEntityExtensionMappings class
*/
});
// add this..
builder.Entity<OrganizationUnit>(b =>
{
b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "OrganizationUnits");
b.ConfigureByConvention();
b.Property(ou => ou.Code).IsRequired().HasMaxLength(OrganizationUnitConsts.MaxCodeLength)
.HasColumnName(nameof(OrganizationUnit.Code));
b.Property(ou => ou.DisplayName).IsRequired().HasMaxLength(OrganizationUnitConsts.MaxDisplayNameLength)
.HasColumnName(nameof(OrganizationUnit.DisplayName));
b.HasMany<OrganizationUnit>().WithOne().HasForeignKey(ou => ou.ParentId);
b.HasMany(ou => ou.Roles).WithOne().HasForeignKey(our => our.OrganizationUnitId).IsRequired();
b.HasIndex(ou => ou.Code);
});
builder.Ignore<OrganizationUnitRole>();
builder.Configureqa();
}
DbContextModelCreatingExtensions:
builder.Entity<UnitCategory>(b =>
{
b.ToTable("UnitCategory");
b.HasMany(x => x.OrganizationUnits).WithOne().HasForeignKey("UnitCategoryId");
b.ConfigureByConvention();
});
EfCoreEntityExtensionMappings:
ObjectExtensionManager.Instance
.MapEfCoreProperty<OrganizationUnit, Guid?>(
"UnitCategoryId",
b => b.HasMaxLength(64)
);