IdentityServer4 icon indicating copy to clipboard operation
IdentityServer4 copied to clipboard

idp claim is missing

Open mikeandersun opened this issue 9 years ago • 12 comments

I have a client that did work fine with IdentityServer v 2.0.0 . I update the package to v 2.0.4 and encounter with this error : idp claim is missing My question is where I can set idp? or where it come from? Thanks

mikeandersun avatar Nov 22 '17 22:11 mikeandersun

This error sounds like it's coming from somewhere in the login UI hosted in IdentityServer. Compare your UI with the quickstart UI to see if there's some missing piece. We expect you to issue a sub claim when you issue the cookie in IdentityServer.

brockallen avatar Nov 22 '17 23:11 brockallen

I inspect the user claims and it contains sub claim. but the idp not exists.

mikeandersun avatar Nov 23 '17 06:11 mikeandersun

How do you sign in the user in IdentityServer (code)?

leastprivilege avatar Nov 23 '17 10:11 leastprivilege

I change await HttpContext.SignInAsync(result.User.Id.ToString(), result.User.UserName, props); to await HttpContext.SignInAsync(result.User.Id.ToString(), result.User.UserName, "local", props); And work fine. Bu I don't know hos to get the IdentityProvider from login controller?

mikeandersun avatar Nov 27 '17 11:11 mikeandersun

So in essence you are doing this:

https://github.com/IdentityServer/IdentityServer4/blob/8e7a4061582ac6bb822238897348f4393fa0e580/src/Host/Quickstart/Account/AccountController.cs#L119

Which I just also tried, and I get an idp claim with value "local". So I can't repro with the info I have right now.

leastprivilege avatar Nov 27 '17 12:11 leastprivilege

Any more info?

leastprivilege avatar Nov 29 '17 14:11 leastprivilege

I ran into this myself this week while showing IdentityServer. It was because I had claims and cookie issued before I had put IdentityServer in the pipeline, I then added IdentityServer and given that I was still logged in, when the token was being issued the old cookie had not been populated via IdentityServer with the right claims (idp).

brockallen avatar Nov 29 '17 17:11 brockallen

Any update on the issue? closing for now - feel free to re-open if it needs further discussion.

leastprivilege avatar Dec 08 '17 09:12 leastprivilege

Hi, I'm experimenting "idp claim is missing" in development environment (not tested in production, yet) with Identity Server v2.1.1 and Asp.Net Core v2.0.5 for HybridAndClientCredentials flow. The thrown exception is:

InvalidOperationException: idp claim is missing IdentityServer4.Extensions.PrincipalExtensions.GetIdentityProvider(IIdentity identity) in PrincipalExtensions.cs, line 203

the cookie ".AspNetCore.Identity.Application" at the moment of the exception was:

CfDJ8P8_6lWZfkhFrngXN9bMj7NCGXzHYrxket0Umm0fyQCr73STnkPvkxe090ZHyeklTl09cYTLxrojxnnqIoRaGYWvnIlYs-v9sKd7_Max8s5Sx9M3Q6DnxWRYAba3rqV_lfWJAVFDp0jOOW9FXwxGvPCPhkFH_hByhkRDbq27YSDDYZ8mIc6_bY-SO7JGFv37HCOa1ocnSd9pRqo_CjlxSr9xBAMibTqZQMZBzMf4EWk3TQ_2dnt88IvJ_xpDq2eZzAH1tjznov3_n2bqrkVEKx6oOERroVm8hvvDuV81zqYC0L3xaWyVHaNWqzkU48Z3KuLAryqEd3gWsK9QKRL_tNaIyKa7aNiuWpAykVpRkbfqgNHbyE68oernv1vmF7geLzhIcItKB2owLvTHNAQhMDs4MSdyeoyrZqkoW3jHnWqKuPPydJUhJupV9sf2RXZUsPxZfl_9Ea-ZtrllA77b_RIlaaCpFFqnXhK7iqLl-PNJVWEHMIfv7MwQ4RMiX8_tkgntGgAo9DI9WTPZo6ZxGqoT1w14sYu9Ot-T6s37kiWiIQiqGbOrZCt14-Vsemaa98MX5HN54-rbtTk44t4t2h7F6-Pchj6bmNleXDxG7DCm9ay5LAmu1vqGnG0l-K-m2qL9KgwIJZ5gRAFKc0cDAhBnh16edltK7nrIlSJWUP3TGPmAGka4rxLVTAD_yt-hS7pUUR_OZwE0dbX-Ob-ziWt4cYofT_c7F2JzI0ucf_dpQ8mV8hj3lPIte0WfAoIvU6eMNBwwa8xs5aysTdb1KMxPhJfOwbFDnSRMui5T7zqHh2V21a42f5cvZdJ6mDc-Go2PiFRvgVcK_OP4Bvk53YYJs5y2iKa1aSy6ja7H0gapnBQzfBFXDuDqHy3573CYiaZfOsQ_IwqXJTPMd6wuHu2iBD13SJk47BCBkTNhs3UMNFmvkKVrhpXzYC6DZO5tDGcaDhypj-oB0IzsiVq7TGgfIrs2NEuwIVBorAfHOr7FKnj0vH0sG5s-aOuXn-uGVtde0lGEbX3sJO1CogbjWwAWTvtv46PwFTv0N_YU0pIL3GQqWWpzCLhP0CalrRcf-C1-_yADmpaXEdDmHjF81ducUQRt1VizPo3BiC0TFbwE-sor9rzKESVyh5YjwcXNS2ugHhW5npgAMuinUJozYxN72FXHm7rZXO6apqh-XbmnfdPyycXUlQZ8LDYtM60Pi3tJrojCHEdJ2C0PFbOfuOY2RmGGL7YwTBTYpuT_5r4Vd4-7HOgVUBAlZjkZeWcMKogQRaDJq7FuMxhYKlNqaaaBDi0WSVz6gAwvIg4Xris03F19Jd--ul0GpyvrvbTgYH25AGSz2Qr7FCUJ-gBWnvmh3AgiplPhD5VULS0p3Wf3_vEnZjbfaEBEZ7s4NuUX6O2AAB4h-8Rj8NyCuavPAEkwMK-7mCFCgkIsrq57Wo1c9cmQJrD5SLBttabDY4536atgu_s4WN3oebt4TXdJqLWQzucm1DzUPaQKgqVeYUK_M8ioVaPikgKuU93QxI4LOpPpxqBo5x0Q4vSGER5UU-A

This exception is raised when I set the "remember me" flag and try to login again after some minutes. Any help would be appreciated. Thanks

gartak avatar Jan 30 '18 10:01 gartak

Solved

In order to get the following working again:

services.AddAuthentication()
    .AddCookie("Cookies")

I had to delete the users from the database, then re-add them. And magically idp claim is missing went away. So changing the authentication scheme after a user is created is going to end up with this error as the user is altered in the database.

To replicate the error use:

services.AddAuthentication()
    .AddCookie("Cookies")

Add a user and check you can login ok. Change the code to:

services.AddAuthentication("Cookies")
    .AddCookie("Cookies")

Go to view grants, and you should now be stuck in a login loop. Change the code back to:

services.AddAuthentication()
    .AddCookie("Cookies")

You now get the `idp claim is missing'

To solve, delete the user, and re-add user again. So something in the AspNetUsers table changed.

sjh37 avatar Jan 10 '19 17:01 sjh37

I too am getting this error.

JohnGalt1717 avatar Feb 22 '19 21:02 JohnGalt1717

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 11 '20 20:01 lock[bot]