Sorry, no error messages, only in the log. Just the test fails. This one and see the log error
class Program
{
private const string ServerUrlBase = "http://localhost:22742/";//62114/";
static void Main(string[] args)
{
RunDemoAsync().Wait();
Console.ReadLine();
}
public static async Task RunDemoAsync()
{
var accessToken = await GetAccessTokenViaOwnerPasswordAsync();
await GetUsersListAsync(accessToken);
}
private static async Task<string> GetAccessTokenViaOwnerPasswordAsync()
{
var disco = await DiscoveryClient.GetAsync(ServerUrlBase);
using (var httpHandler = new HttpClientHandler())
{
httpHandler.CookieContainer.Add(new Uri(ServerUrlBase), new Cookie(MultiTenancyConsts.TenantIdResolveKey, "2")); //Set TenantId
var tokenClient = new TokenClient(disco.TokenEndpoint, "client", "def2edf7-5d42-4edc-a84a-30136c340e13",
//"def2edf7-5d42-4edc-a84a-30136c340e13",
httpHandler);
//var tokenResponse = await tokenClient.RequestResourceOwnerPasswordAsync("alice", "alice");
var tokenResponse = await tokenClient.RequestResourceOwnerPasswordAsync("admin", "Vlad1!");
if (tokenResponse.IsError)
{
Console.WriteLine("Error: ");
Console.WriteLine(tokenResponse.Error);
}
Console.WriteLine(tokenResponse.Json);
return tokenResponse.AccessToken;
}
}
private static async Task GetUsersListAsync(string accessToken)
{
using (var client = new HttpClient())
{
client.SetBearerToken(accessToken);
var response = await client.GetAsync($"{ServerUrlBase}api/services/app/User/getUsers");
if (!response.IsSuccessStatusCode)
{
Console.WriteLine(response.StatusCode);
return;
}
var content = await response.Content.ReadAsStringAsync();
var ajaxResponse = JsonConvert.DeserializeObject<AjaxResponse<PagedResultDto<UserListDto>>>(content);
if (!ajaxResponse.Success)
{
throw new Exception(ajaxResponse.Error?.Message ?? "Remote service throws exception!");
}
Console.WriteLine();
Console.WriteLine("Total user count: " + ajaxResponse.Result.TotalCount);
Console.WriteLine();
foreach (var user in ajaxResponse.Result.Items)
{
Console.WriteLine($"### UserId: {user.Id}, UserName: {user.UserName}");
Console.WriteLine(user.ToJsonString(indented: true));
}
}
}
}
}
INFO 2018-02-02 17:43:07,172 [12 ] Server4.Hosting.IdentityServerMiddleware - Invoking IdentityServer endpoint: IdentityServer4.Endpoints.DiscoveryEndpoint for /.well-known/openid-configuration
INFO 2018-02-02 17:43:07,240 [12 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 181.0179ms 200 application/json; charset=UTF-8
INFO 2018-02-02 17:43:07,404 [3 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET <a class="postlink" href="http://localhost:22742/.well-known/openid-configuration/jwks">http://localhost:22742/.well-known/open ... ation/jwks</a>
INFO 2018-02-02 17:43:07,413 [3 ] Server4.Hosting.IdentityServerMiddleware - Invoking IdentityServer endpoint: IdentityServer4.Endpoints.DiscoveryKeyEndpoint for /.well-known/openid-configuration/jwks
INFO 2018-02-02 17:43:07,450 [3 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 46.1597ms 200 application/json; charset=UTF-8
INFO 2018-02-02 17:43:10,299 [12 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 POST <a class="postlink" href="http://localhost:22742/connect/token">http://localhost:22742/connect/token</a> application/x-www-form-urlencoded 52
INFO 2018-02-02 17:43:10,323 [12 ] Server4.Hosting.IdentityServerMiddleware - Invoking IdentityServer endpoint: IdentityServer4.Endpoints.TokenEndpoint for /connect/token
INFO 2018-02-02 17:43:10,522 [12 ] tIdentity.ResourceOwnerPasswordValidator - Credentials validated for username: admin
INFO 2018-02-02 17:43:10,580 [12 ] Server4.Validation.TokenRequestValidator - Token request validation success
{
"ClientId": "client",
"GrantType": "password",
"Scopes": "default-api",
"UserName": "admin",
"Raw": {
"grant_type": "password",
"username": "admin",
"password": "REDACTED"
}
}
INFO 2018-02-02 17:43:10,898 [9 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 598.9385ms 200 application/json; charset=UTF-8
INFO 2018-02-02 17:43:11,830 [3 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET <a class="postlink" href="http://localhost:22742/api/services/app/User/getUsers">http://localhost:22742/api/services/app/User/getUsers</a>
INFO 2018-02-02 17:43:11,888 [3 ] uthentication.JwtBearer.JwtBearerHandler - Failed to validate the token eyJhbGciOiJSUzI1NiIsImtpZCI6IjEyMWJmMzJhNmIwN2NkYzRjMTIxZmFiNDVlZGZmZjQ0IiwidHlwIjoiSldUIn0.eyJuYmYiOjE1MTc2MjIxOTAsImV4cCI6MTUxNzYyNTc5MCwiaXNzIjoiaHR0cDovL2xvY2FsaG9zdDoyMjc0MiIsImF1ZCI6WyJodHRwOi8vbG9jYWxob3N0OjIyNzQyL3Jlc291cmNlcyIsImRlZmF1bHQtYXBpIl0sImNsaWVudF9pZCI6ImNsaWVudCIsInN1YiI6IjYiLCJhdXRoX3RpbWUiOjE1MTc2MjIxOTAsImlkcCI6ImxvY2FsIiwiaHR0cDovL3d3dy5hc3BuZXRib2lsZXJwbGF0ZS5jb20vaWRlbnRpdHkvY2xhaW1zL3RlbmFudElkIjoiMyIsInNjb3BlIjpbImRlZmF1bHQtYXBpIl0sImFtciI6WyJwd2QiXX0.PQy9dDx-h6-uajt1233kJEXgY3TCKBXjUZJ4uJ7oK6cfkhOiImWzLwHVbheDNolumS3smyi-5ZjIW4jUSt2DY8wD9oYIvlOWbi3uuaT5392hxwtxGQ8NU_345hAXBhCemiWC7jAM7v_B1NBuuOmqvfp0X0H3z7YVYCUb9D-wzKa13ynkGLUGwVbywDviPXH1ZYcL5uGG-8uRvFt3MRdiZwgAyr9x4PoG2dFwlVZLXBRvG3R4Vw1zFbm7wnbdjXR-b2pj3rg_Ud762mfB37MO70V2DWns1s6cvuNfpLBv2t1LD2gKY7Makc9gHSxqvQ6PglB5OZjtoUgOHmzpbu78oQ.
Microsoft.IdentityModel.Tokens.SecurityTokenSignatureKeyNotFoundException: IDX10501: Signature validation failed. Unable to match 'kid': '121bf32a6b07cdc4c121fab45edfff44',
token: '{"alg":"RS256","typ":"JWT","kid":"121bf32a6b07cdc4c121fab45edfff44"}.{"nbf":1517622190,"exp":1517625790,"iss":"http://localhost:22742","aud":["http://localhost:22742/resources","default-api"],"client_id":"client","sub":"6","auth_time":1517622190,"idp":"local","http://www.aspnetboilerplate.com/identity/claims/tenantId":"3","scope":["default-api"],"amr":["pwd"]}'.
at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateSignature(String token, TokenValidationParameters validationParameters)
at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, TokenValidationParameters validationParameters, SecurityToken& validatedToken)
at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.<HandleAuthenticateAsync>d__6.MoveNext()
INFO 2018-02-02 17:43:11,890 [3 ] uthentication.JwtBearer.JwtBearerHandler - Bearer was not authenticated. Failure message: IDX10501: Signature validation failed. Unable to match 'kid': '121bf32a6b07cdc4c121fab45edfff44',
token: '{"alg":"RS256","typ":"JWT","kid":"121bf32a6b07cdc4c121fab45edfff44"}.{"nbf":1517622190,"exp":1517625790,"iss":"http://localhost:22742","aud":["http://localhost:22742/resources","default-api"],"client_id":"client","sub":"6","auth_time":1517622190,"idp":"local","http://www.aspnetboilerplate.com/identity/claims/tenantId":"3","scope":["default-api"],"amr":["pwd"]}'.
ERROR 2018-02-02 17:43:11,959 [3 ] nostics.DeveloperExceptionPageMiddleware - An unhandled exception has occurred while executing the request
System.MissingMethodException: Method not found: 'System.ValueTuple2<System.String,System.String> IdentityModel.Client.DiscoveryClient.ParseUrl(System.String)'. at IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationOptions.ConfigureJwtBearer(JwtBearerOptions jwtOptions) at Microsoft.Extensions.Options.OptionsFactory
1.Create(String name)
at Microsoft.Extensions.Options.OptionsMonitor1.<>c__DisplayClass10_0.<Get>b__0() at System.Lazy
1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy
1.CreateValue()
at Microsoft.Extensions.Options.OptionsCache1.GetOrAdd(String name, Func
1 createOptions)
at Microsoft.Extensions.Options.OptionsMonitor1.Get(String name) at Microsoft.AspNetCore.Authentication.AuthenticationHandler
1.<InitializeAsync>d__42.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationHandlerProvider.<GetHandlerAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at IdentityServer4.Hosting.FederatedSignOut.FederatedSignoutAuthenticationHandlerProvider.<GetHandlerAsync>d__3.MoveNext() in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Hosting\FederatedSignOut\FederatedSignoutAuthenticationHandlerProvider.cs:line 33
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.AspNetCore.Authentication.AuthenticationService.<AuthenticateAsync>d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationHandler.<HandleAuthenticateAsync>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()
at Microsoft.AspNetCore.Authentication.AuthenticationHandler1.<AuthenticateAsync>d__47.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()
at Microsoft.AspNetCore.Authentication.AuthenticationService.<AuthenticateAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.AspNetZeroCore.Web.Authentication.JwtBearer.JwtTokenMiddleware.<>c__DisplayClass0_0.<<UseJwtTokenMiddleware>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.AspNetZeroCore.Web.Authentication.JwtBearer.JwtTokenMiddleware.<>c__DisplayClass0_0.<<UseJwtTokenMiddleware>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.<Invoke>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
INFO 2018-02-02 17:43:12,054 [3 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 224.6711ms 500 text/html; charset=utf-8
Update for all, the minute I add reference to the mongodb project for IdentityServer4 from <a class="postlink" href="https://github.com/diogodamiani/IdentityServer4.Contrib.MongoDB.git">https://github.com/diogodamiani/Identit ... ongoDB.git</a> it breaks ASP.NET Zero working with IdentityServer4
I would like to extend feature properties, for example with Display Order and Image.
My FeatureMetadata is extended:
public class FeatureMetadata
{
public const string CustomFeatureKey = "FeatureMetadata";
public FeatureMetadata()
{
TextHtmlColor = value => "inherit";
IsVisibleOnPricingTable = false;
Image = "https://<default_image_path>.png";
Order = 0;
}
public Func<string, ILocalizableString> ValueTextNormalizer { get; set; }
public bool IsVisibleOnPricingTable { get; set; }
public Func<string, string> TextHtmlColor { get; set; }
public string Image { get; set; }
public int Order { get; set; }
}
My DTO is extended:
public class FlatFeatureSelectDto
{
public string ParentName { get; set; }
public string Name { get; set; }
public string DisplayName { get; set; }
public string Description { get; set; }
public string DefaultValue { get; set; }
public IInputType InputType { get; set; }
public string TextHtmlColor { get; set; }
public string Image { get; set; }
public int Order { get; set; }
}
But when mapping is run, it does not automap
var flatFeatures = ObjectMapper
.Map<List<FlatFeatureSelectDto>>(features)
.OrderBy(f => f.Order)
.ToList();
What am I missing. Its a simple use case for features, I want to order them and display something next to it in edition selections.
Thanks for insights.
Thanks, I just downloaded asp.net zero bundle 1 week ago, so I got an old version! Hmmmm.
Is there an easy way to bring the version or I have to import one fix at a time?
When you setup edition to have monthly and annual price and go edit again it fails to show price you set. While price is set in database correctly, mapping between database object and dto object fails to map decimals. Here is a link where it fails.
editionEditDto = ObjectMapper.Map<EditionEditDto>(edition);
edition has values for monthlyprice and annualprice, while editionEditDto has them as nulls after mapping.
Any advise how to fix this bug?
Looks like a proper way to register is
Configuration.IocManager.Register<ITenantResolveContributor, DefaultTenantResolveContributor>(DependencyLifeStyle.Transient);
It worked.
It is created in my new project I call MyProject.Extensions
I tried adding this code in core module but it did not help: Configuration.IocManager.IocContainer.Register( Component.For<ITenantResolveContributor>() .ImplementedBy<DefaultTenantResolveContributor>() .LifestyleTransient()); }
I have implemented custom resolver, catch all situation, resolves to default tenant id. See
//https://aspnetboilerplate.com/Pages/Documents/Multi-Tenancy
public class DefaultTenantResolveContributor : ITenantResolveContributor, ITransientDependency
{
private readonly IHttpContextAccessor _httpContextAccessor;
private static int DEFAULT_TENANT = 3;
public DefaultTenantResolveContributor(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public int? ResolveTenantId()
{
return DEFAULT_TENANT;
}
}
It is added in PreInitialize in Core module
Configuration.MultiTenancy.Resolvers.Add<DefaultTenantResolveContributor>();
When application runs, it fails to load it. With exception:
Castle.MicroKernel.ComponentNotFoundException
HResult=0x80131500
Message=No component for supporting the service DefaultTenantResolveContributor was found
Source=Castle.Windsor
StackTrace:
at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy)
at Abp.Dependency.IocResolverExtensions.ResolveAsDisposable[T](IIocResolver iocResolver, Type type)
at Abp.MultiTenancy.TenantResolver.GetTenantIdFromContributors()
at Abp.MultiTenancy.TenantResolver.ResolveTenantId()
at Abp.Runtime.Session.ClaimsAbpSession.get_TenantId()
at Abp.Domain.Uow.UnitOfWorkBase.SetFilters(List1 filterOverrides) at Abp.Domain.Uow.UnitOfWorkBase.Begin(UnitOfWorkOptions options) at Abp.Domain.Uow.UnitOfWorkManager.Begin(UnitOfWorkOptions options) at MyProject.Migrations.Seed.SeedHelper.WithDbContext[TDbContext](IIocResolver iocResolver, Action
1 contextAction) in C:\Dev\MyProject\Base\aspnet-core\src\MyProject.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs:line 38
at MyProject.Migrations.Seed.SeedHelper.SeedHostDb(IIocResolver iocResolver) in C:\Dev\MyProject\Base\aspnet-core\src\MyProject.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs:line 18
at MyProject.EntityFrameworkCore.MyProjectEntityFrameworkCoreModule.PostInitialize() in C:\Dev\MyProject\Base\aspnet-core\src\MyProject.EntityFrameworkCore\EntityFrameworkCore\MyProjectEntityFrameworkCoreModule.cs:line 51
at System.Collections.Generic.List1.ForEach(Action
1 action)
at Abp.AbpBootstrapper.Initialize()
Please help what I am missing as I followed the doc at <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Multi-Tenancy">https://aspnetboilerplate.com/Pages/Doc ... ti-Tenancy</a>
Thank you.
VS 2017 has built in support for npm and webpack and angular cli. It would be nice if you can provide steps how to update AngurlarUI project so it can be compiled, run and debugged right from Visual Studio.
Anyone have tried to that? I understand I can keep doing cli. It would nice to use VS debugger.
Thanks.
I already did. There are a lot of good features in your framework that can be uncovered with a few lines of code.