.Net Core Authentication Continuously Redirects to Authorize Request as an Infinite Loop
Last Updated:
Overview
.Net core authentication continuously redirects to the /authorize request as an infinite loop. The /authorize request will be followed by a 'Malformed Response Cookies' showing information about the cookie in the dev console.
Applies To
- .Net
- Authorize request
- Infinite authorize request loop
- Okta self-hosted sign-in Widget
- Okta hosted sign-in widget
- Sign-in widget
- Authorization code flow
Cause
This may happen because of the cookie size that is stored in the web browser, and according to RFC 6265, the maximum size should be 4069. Since the cookie carries information/data, this may be happen if there were lots of groups set up in the org and there was a group claim added that returns all the groups like 'Matches regex .*' or of claim that returns a lot of information in the ID/Access token.
Solution
Add precise group claims that returns the groups / claim information required.
Using a custom authorization server
In the Okta Dashboard Console, in Security > API > Choose the authorization server > Claims tab, in case of using a custom authorization server.
Using an org authorization server
Under Applications > Applications > Choose the app > Signon tab > OpenID Connect ID Token.
If the cookie size is required to be large, then ChunkingCookieManager.Chunk size is a potential solution, as mentioned in this Microsoft Documentation.
