Cookie based authentication in .NET 6 Core API using Identity #51607
Replies: 3 comments 3 replies
-
You say you're using Identity, but only show Cookie auth above. Please show the rest of your auth setup. ".AspNetCore.Identity.Application" comes from |
Beta Was this translation helpful? Give feedback.
-
Hi @sohaibameenpk007. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Beta Was this translation helpful? Give feedback.
-
Hi @Tratcher can you further explain about the auth setup please? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there an existing issue for this?
Describe the bug
Hello Everyone,
I have created a new .NET Core API project in .NET 6 and implemented Cookie authentication using Identity.
I have created the method below to create cookie
I have added configuration in program.cs
System create multiple cookies ".AspNetCore.Identity.Application" and my ".MyCookieName" which seems strange to me because it should only create one cookie. There are couple of problems that I have to report
1- Multiple Cookies are being generated
2- If I pass my cookie ".MyCookieName" to be authorized then request is not being authorized because it does not have the claims in it but it works fine with ".AspNetCore.Identity.Application" since it has the claims.
3- I can not change the name of ".AspNetCore.Identity.Application" cookie and the expiration time remains 14 days
4- API returns 404 in case if request is not authorized but it should return 401
Please review this and provide your feedback just to see where do I doing things wrong.
Best,
Sohaib
Expected Behavior
1- One cookie should be created with proper name, expiration time and claims in it which can be authorized properly.
2- API should return 401 instead of 404 when request is not authorized.
Steps To Reproduce
Exceptions (if any)
.NET Version
.NET 6
Anything else?
Beta Was this translation helpful? Give feedback.
All reactions