I have done following configurations
- Created loadbalancer
- Created user pool
- created client with secret and enabled authorization code grant and openid scope
Configured authentication in loadbalancer with above created resource details
- Created a listener rule with cognito authentication
- Added needed configuration including scope as
openid
- Configured
deny
for unauthenticated requests
Problem is when I call the loadbalancer url with the id token or access token(as cookies) that is retrieved from another app client configured to application, The loadbalancer is returning 401
When I try the the configuration authenticate
for unauthenticated request. I was able to successfully call the loadbalancer url where I am getting success response(loadbalancer will redirect to cognito login and after successfull login, loadbalancer will set the cookies).
The cookie that being set in the success scenario is being sharded
The cookie entry were like cookie_name-0
and cookie_name-1
(Which I do not know how to reproduce/recreate manually)
The below excerpt from aws docs confirms above sharding behaviour
The load balancer creates the authentication session cookie and sends it to the client so that the client's user agent can send the cookie to the load balancer when making requests. Because most browsers limit a cookie to 4K in size, the load balancer shards a cookie that is greater than 4K in size into multiple cookies. If the total size of the user claims and access token received from the IdP is greater than 11K bytes in size, the load balancer returns an HTTP 500 error to the client and increments the ELBAuthUserClaimsSizeExceeded metric.
- How can I successfully call the loadbalancer url with the configuration for unauthenticated request as
deny
where I need to set the cookie manually? - Manually generated id token/ access token length are around 1k in size, why the loadbalancer retrieved token exceeds 4k in size?
https://aws.amazon.com/premiumsupport/knowledge-center/elb-configure-authentication-alb/