C
C#15mo ago
Philskillz_

✅ ASP.NET EFC MVC deletes authentication cookie after next request.

I've been having this issue that my asp.net app is deleting the login cookie right next request after it set it. When i post to /login i get this response header:
Set-Cookie:
.AspNetCore.Cookies=CfDJ8JKa6jJ<shortened>; expires=Wed, 20 Sep 2023 17:55:07 GMT; path=/; secure; samesite=lax; httponly
Set-Cookie:
.AspNetCore.Cookies=CfDJ8JKa6jJ<shortened>; expires=Wed, 20 Sep 2023 17:55:07 GMT; path=/; secure; samesite=lax; httponly
After that it redirects me to /me page and /me page responds with this header (It unsets the cookie)
Set-Cookie: .AspNetCore.Cookies=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; secure; samesite=lax; httponly
Set-Cookie: .AspNetCore.Cookies=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; secure; samesite=lax; httponly
I have no clue why it does that. Please help me
12 Replies
Philskillz_
Philskillz_OP15mo ago
Btw here is the full code
JakenVeina
JakenVeina15mo ago
let's see your config for the auth middleware
Philskillz_
Philskillz_OP15mo ago
GitHub
TheSKZWeb/TheSKZWeb/Program.cs at main · philskillz-coder/TheSKZWeb
Contribute to philskillz-coder/TheSKZWeb development by creating an account on GitHub.
GitHub
TheSKZWeb/TheSKZWeb/AuthorizationPolicies/PermissionPolicy.cs at ma...
Contribute to philskillz-coder/TheSKZWeb development by creating an account on GitHub.
GitHub
TheSKZWeb/TheSKZWeb/Middleware/LoginManagerMiddleware.cs at main · ...
Contribute to philskillz-coder/TheSKZWeb development by creating an account on GitHub.
Philskillz_
Philskillz_OP15mo ago
also the repo was private now its public
JakenVeina
JakenVeina15mo ago
what's your intention for having both JWT and Cookie authentication configured? I'll wager that's where the issue's coming from the login action sets a cookie for cookie scheme, but what's triggering the auth failure is the bearer scheme set some breakpoints in that ForwardDefaultSelector delegate, and see if it's behaving the way you intend
Philskillz_
Philskillz_OP15mo ago
I had this jwt and cookie configuration already when I created my original app a year ago. Now Im using it again and it does not work Will try the breakpoint but I didn't understand where you meant to place it. Can you explain it again please? omfg i so stupid
Philskillz_
Philskillz_OP15mo ago
No description
Philskillz_
Philskillz_OP15mo ago
it signs out if users dont have permission but this permission does not exist and it returns false
JakenVeina
JakenVeina15mo ago
inside the ForwardDefaultSelector delegate
Philskillz_
Philskillz_OP15mo ago
Ok I fixed it
JakenVeina
JakenVeina15mo ago
sweet
Philskillz_
Philskillz_OP15mo ago
How do I close this ticket?
Want results from more Discord servers?
Add your server