Closed t9creative-zz closed 5 years ago
it looks like there is some issues with authorization.
can you paste your Startup.cs
?
Sure, here ya go
using DbLocalizationProvider.AdminUI.AspNetCore; using DbLocalizationProvider.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.UI; using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using System.Collections.Generic; using System.Globalization; using TestLocalizationIdentity.Data;
namespace TestLocalizationIdentity { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; }
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
services.AddDefaultIdentity<IdentityUser>()
.AddDefaultUI(UIFramework.Bootstrap4)
.AddEntityFrameworkStores<ApplicationDbContext>();
services.AddLocalization();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
.AddViewLocalization()
.AddDataAnnotationsLocalization();
services.Configure<RequestLocalizationOptions>(opts =>
{
var supportedCultures = new List<CultureInfo>
{
new CultureInfo("en"),
new CultureInfo("es")
};
opts.DefaultRequestCulture = new RequestCulture("en");
opts.SupportedCultures = supportedCultures;
opts.SupportedUICultures = supportedCultures;
});
services.AddDbLocalizationProvider(cfg =>
{
//cfg.Connection = "DefaultConnection";
cfg.EnableInvariantCultureFallback = true;
cfg.EnableInvariantCultureFallback = true;
});
services.AddDbLocalizationProviderAdminUI(_ =>
{
_.RootUrl = "/translate";
_.ShowInvariantCulture = true;
_.ShowHiddenResources = false;
_.AuthorizedAdminRoles.Add("Admin");
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
var options = app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>();
app.UseRequestLocalization(options.Value);
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseAuthentication();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
app.UseDbLocalizationProvider();
//app.UseDbLocalizationClientsideProvider(path: "/jsl10n");
app.UseDbLocalizationProviderAdminUI();
}
}
}
what does https://server/localization-admin/api/service/get
return?
If I try to access that with "localization-admin" (Note, I switched the root) it's a 404 page.
If I try /translate/api/service/get (That I switched it to 'translate') I get an "Access denied You do not have access to this resource." message
I removed the custom root url, still getting that access denied message.
is role based authorization working in other places?
in what roles user you are using is assigned to? can you check via code during runtime as well?
Appreciate the responses. It seems the AddDefaultIdentity instead of AddIdentity in ConfigureServices was the culprit. I am able to access everyhting now.
glad you solved! :) no much help from my side ..
Clean install of an Asp.Net Core 2.2 application with Identity and individual accounts.
Have created a user and a role, added the user and the user to the role. Can access the localization-admin interface however only the search/filter bar shows up and the "Export" and "Settings" buttons in the top-right.
I'm getting the following error:
node_modules.vue.dist.vue.min.js:6 TypeError: Cannot read property 'showHiddenResources' of undefined at Rt.eval (eval at Tn (node_modules.vue.dist.vue.min.js:6),:3:671)
at Rt.t._render (node_modules.vue.dist.vue.min.js:6)
at Rt.r (node_modules.vue.dist.vue.min.js:6)
at Kr.get (node_modules.vue.dist.vue.min.js:6)
at Kr.run (node_modules.vue.dist.vue.min.js:6)
at ht (node_modules.vue.dist.vue.min.js:6)
at Array. (node_modules.vue.dist.vue.min.js:6)
at J (node_modules.vue.dist.vue.min.js:6)
K @ node_modules.vue.dist.vue.min.js:6
Any idea what's going on?