apereo / dotnet-cas-client

Apereo .NET CAS Client
Apache License 2.0
234 stars 172 forks source link

localhost redirected you too many times #100

Closed RMMamun closed 4 years ago

RMMamun commented 4 years ago

Dear All,

My ASP.Net-4 web application cannot run, it's just showing error "localhost redirected you too many times". I have run the project successfully by skipping the authentication phase for few times. After then its showing the error and cannot run it any how. I cleared cookies, cashes, even I have reinstalled the browser also, but did not work.

I'll appreciate your help.

Thanks.

phantomtypist commented 4 years ago

I'm pretty sure I know what's causing this. Let me go hunt down the prior issue(s) where I explained it because it's quite lengthy.

phantomtypist commented 4 years ago

FYI you'll need to make sure you're targeting at minimum 4.5.x or higher (e.g. up to 4.8.x)

phantomtypist commented 4 years ago

@RMMamun go head over and check out this issue and my comments. https://github.com/apereo/dotnet-cas-client/issues/72

phantomtypist commented 4 years ago

@RMMamun if that resolves your issue please close this issue.

RMMamun commented 4 years ago

Hi, I am using .Net framework 4, Is that you have asked?

phantomtypist commented 4 years ago

@RMMamun you can't be targeting exactly 4.0. You have to target 4.5.x or higher. FWIW the server (and your computer) also have to have .NET 4.x updated to be at least 4.5.x or higher.

RMMamun commented 4 years ago

I have update target to 4.6.2, but still same error showing.

TheHokieCoder commented 4 years ago

@RMMamun another possible cause for the too many redirects error is if the time on your server where the app is hosted differs too much from the time of your CAS server. This can cause ALL service tickets to be invalidated, causing the endless redirection loop. You can test for this by setting the ticketTimeTolerance attribute of the casClientConfig section to a larger/not sane value. If you are using a version > 1.1.0 of DotNetCasClient, this should be defaulting to 30,000 milliseconds, or 30 seconds. Earlier versions were set to 5,00 milliseconds, or 5 seconds.

If that ends up being the culprit, make sure you change the tolerance value back to a sane (30s or less) value and fix the real problem that your servers' times are incorrect. If you leave the value too large, it will open your system for easier attacks.

phantomtypist commented 4 years ago

@RMMamun you went through everything I said in that other thread and doubled check all of that both on your server/computer and the actual CAS server?

phantomtypist commented 4 years ago

@RMMamun another possible cause for the too many redirects error is if the time on your server where the app is hosted differs too much from the time of your CAS server. This can cause ALL service tickets to be invalidated, causing the endless redirection loop. You can test for this by setting the ticketTimeTolerance attribute of the casClientConfig section to a larger/not sane value. If you are using a version > 1.1.0 of DotNetCasClient, this should be defaulting to 30,000 milliseconds, or 30 seconds. Earlier versions were set to 5,00 milliseconds, or 5 seconds.

If that ends up being the culprit, make sure you change the tolerance value back to a sane (30s or less) value and fix the real problem that your servers' times are incorrect. If you leave the value too large, it will open your system for easier attacks.

Yes, timing can be an issue as well.

RMMamun commented 4 years ago

Hi, FYI, I am not using CAS in my project. And my OS is win7.

RMMamun commented 4 years ago

@phantomtypist, I have found the problematic point, in my default page i used a button to navigate a page, but there is an error on that page. When I removed the button from my default page the application is running properly. Although my new page is not opening due to error "A server error occurred when we tried to complete your request. Please try again after some time. If the problem persists, please contact support.", but it's another thread.

Thank you for your quick responses.

phantomtypist commented 4 years ago

@RMMamun wait, I'm confused here. So you're not using a CAS server as the mechanism to provide authentication of users in your application? I gotta ask, what lead you down the path to install this NuGet package or use this code (whichever route you went)?

If you're not authenticating users of your application against CAS (Central Authentication Service) for single sign on purposes then there is no need to install this NuGet package nor use this code in your application.