Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Multiple implicit clients cannot be stored in cookie #2446

Closed
donruperto opened this issue Jan 19, 2016 · 18 comments
Closed

Multiple implicit clients cannot be stored in cookie #2446

donruperto opened this issue Jan 19, 2016 · 18 comments

Comments

@donruperto
Copy link

Hi,

I´m using two implicit clients and an exception occurs when IdentityServer tries to save them in the cookie idsvr.clients

The problem is in the method ClientListCookie.SetClients - The value created by JsonConvert.SerializeObject is not valid for a cookie.

Rupert

@brockallen
Copy link
Member

Do you have an example of the invalid value?

@donruperto
Copy link
Author

For example, when using "client1" and "client2" the following exception occurs:

ArgumentException: Invalid cookie value: %5B%22client1%22,%22client2%22%5D

The appropriate JSON-String is: ["client1","client2"]

@brockallen
Copy link
Member

ok, thanks. i'll look into it.

@donruperto
Copy link
Author

thank you

@brockallen
Copy link
Member

Also, do you have a call stack for the error?

@brockallen
Copy link
Member

I'm not able to repro this. When the JSON is sent into the API to set the cookie, it seems it's being properly encoded internally in the Katana layer. I used the same "client1" & "client2" values you are using as well.

@donruperto
Copy link
Author

I just used the Mvc sample of IdentityServer4 and added another MVC Client. Here´s the callstack:

ArgumentException: Invalid cookie value: %5B%22mvc_implicit%22,%22mvc_implicit2%22%5D
Parametername: value
bei Microsoft.Net.Http.Headers.CookieHeaderValue.CheckValueFormat(String value, String parameterName)
bei Microsoft.Net.Http.Headers.SetCookieHeaderValue.set_Value(String value)
bei Microsoft.Net.Http.Headers.SetCookieHeaderValue..ctor(String name, String value)
bei Microsoft.AspNet.Http.Internal.ResponseCookies.Append(String key, String value, CookieOptions options)
bei IdentityServer4.Core.Hosting.ClientListCookie.SetCookie(String value)
bei IdentityServer4.Core.Hosting.ClientListCookie.SetClients(IEnumerable1 clients) bei IdentityServer4.Core.Hosting.ClientListCookie.AddClient(String clientId) bei IdentityServer4.Core.Endpoints.Results.AuthorizeEndpointResultFactory.CreateAuthorizeResultAsync(AuthorizeResponse response) bei IdentityServer4.Core.Endpoints.Results.AuthorizeEndpointResultFactory.<CreateAuthorizeResultAsync>d__12.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
bei IdentityServer4.Core.Endpoints.AuthorizeEndpoint.d__16.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter1.GetResult() bei IdentityServer4.Core.Endpoints.AuthorizeEndpoint.<ProcessAuthorizeRequestAsync>d__13.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
bei IdentityServer4.Core.Endpoints.AuthorizeEndpoint.d__12.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter1.GetResult() bei IdentityServer4.Core.Endpoints.AuthorizeEndpoint.<ProcessAsync>d__9.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
bei IdentityServer4.Core.Hosting.IdentityServerMiddleware.d__3.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()
bei IdentityServer4.Core.Hosting.BaseUrlMiddleware.d__2.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()
bei Microsoft.AspNet.Authentication.AuthenticationMiddleware1.<Invoke>d__18.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei Microsoft.AspNet.Authentication.AuthenticationMiddleware1.d__18.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()
bei Microsoft.AspNet.Cors.Infrastructure.CorsMiddleware.d__7.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()
bei Microsoft.AspNet.IISPlatformHandler.IISPlatformHandlerMiddleware.d__8.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()
bei Microsoft.AspNet.Diagnostics.DeveloperExceptionPageMiddleware.d__7.MoveNext()

@brockallen
Copy link
Member

I see a comma in there -- somehow that's getting in there and affecting it I think. That's not a properly url encoded value, so I'm stumped how that's getting in there.

This happens consistently for you? I'd hope this is not somehow related to locale.

Again, I'm stumped.

@donruperto
Copy link
Author

Yes it happens consistently with IdentityServer3 (v2.3) and IdentityServer4. I also created a standard ASP.NET MVC5 project and added a cookie the same way by serializing it with JsonConvert.SerializeObject in the Index action of the HomeController. The same exception occurs.

The stack trace is from from your IdentityServer4 sample:
https://github.com/IdentityServer/IdentityServer4.Samples/tree/dev/Mvc

I just added another MvcClient using another implicit client. So the configuration of the IdentityServer was not adjusted. That´s strange...

@donruperto
Copy link
Author

Here´s my test project where I´m trying to set a cookie in the Index action of the home controller. If this is working on your machine then it must be a local problem.

https://github.com/donruperto/CookieTest.git

@brockallen
Copy link
Member

I also created a standard ASP.NET MVC5 project and added a cookie the same way by serializing it with JsonConvert.SerializeObject in the Index action of the HomeController. The same exception occurs.

This tells me you should be opening an issue with Microsoft, as it's something from Katana.

@donruperto
Copy link
Author

Thanks a lot. After a search in the Microsoft Git repository I found an open issue relating to the problem:

aspnet/HttpAbstractions#535

Sorry this should have been my first investigation target.

@brockallen
Copy link
Member

Ok, I'll close this given that it seems to be a katana ASP.NET 5/ASP.NET Core issue. Thanks and keep us posted on it.

@brockallen
Copy link
Member

Also, this is happening for you in Katana, yes? You should update that thread and let them know.

@brockallen
Copy link
Member

@donruperto Can you confirm if this was happening to you in IdSvr3 or IdSvr4?

@donruperto
Copy link
Author

This was happening in IdSvr4 (ASP.NET 5 Webproject). It´s working correctly with IdSvr3 (ASP.NET 4 Webproject)

@brockallen
Copy link
Member

Ah ok, so my confusion was that this issue was opened here (and not in the IdSvr4 repo). Thx for the update.

@donruperto
Copy link
Author

Ah sorry, that was my fault.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants