Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application load balancer session cookie's expiration is extremely high

This may sound like a very trivial doubt, but I need some help here.

I have set up Application load balancer with OIDC authentication. After logging into my application, using chrome developer tool I looked into the client application cookie. Found that AWSELBAuthSessionCookie-0 and AWSELBAuthSessionCookie-1 have an expiry 2070-10-04T05:02:12.122Z which is almost 50 years from now. Since the ALB isn't forwarding this cookie to my application (EC2) which resides behind the ALB, I am unable to reset the cookie's expiration. I am using Flask to read the headers. Any leads to reduce the AWSELBAuthSessionCookie's expiry will be helpful.

like image 257
missing-semi-colon Avatar asked May 18 '20 14:05

missing-semi-colon


People also ask

What is the best method for maintaining the application session state when using Elastic load balancer?

However, you can use the sticky session feature (also known as session affinity) to enable the load balancer to bind a user's session to a specific target. This ensures that all requests from the user during the session are sent to the same target.

What is session persistence in load balancer?

Session stickiness, a.k.a., session persistence, is a process in which a load balancer creates an affinity between a client and a specific network server for the duration of a session, (i.e., the time a specific IP spends on a website).

How do you increase application load balancer timeout?

To update the idle timeout value using the consoleOn the navigation pane, under LOAD BALANCING, choose Load Balancers. Select the load balancer. On the Description tab, choose Edit attributes. On the Edit load balancer attributes page, enter a value for Idle timeout, in seconds.

What is the “load balancer session cookie” feature?

This new feature helps customers ensure that clients connect to the same load balancer target for the duration of their session using application cookies.

How do I manage sticky sessions in application load balancers?

To use sticky sessions, the client must support cookies. Application Load Balancers support both duration-based cookies and application-based cookies. The key to managing sticky sessions is determining how long your load balancer should consistently route the user's request to the same target.

What is the session cookie used for?

The cookie is used to map the session to the target. If your application does not have its own session cookie, you can specify your own stickiness duration and manage how long your load balancer should consistently route the user's request to the same target.

What is the expiry date of awselbauthsessioncookie-0?

I have set up Application load balancer with OIDC authentication. After logging into my application, using chrome developer tool I looked into the client application cookie. Found that AWSELBAuthSessionCookie-0 and AWSELBAuthSessionCookie-1 have an expiry 2070-10-04T05:02:12.122Z which is almost 50 years from now.


Video Answer


1 Answers

quite an old question already but here are my 2 cents:

  • invalidating a cookie is somehow just a set-cookie with an expired date, so I don't think you need to be able to read the cookie from the request to invalidate it. I have not tried but I would just do something like Set-Cookie "AWSELBAuthSessionCookie-0=deleted;path=/;expires=Thu, 01 Jan 1970 00:00:00 GMT;"

  • for the 2nd point (from @codematix), to logout you need to invalidate the auth cookie AND to redirect the user the logout page configured in your IDP (probably to also invalidate the tokens, otherwise the ALB would just revalidate the tokens and re-create a session). See https://docs.aws.amazon.com/elasticloadbalancing/latest/application/listener-authenticate-users.html#authentication-logout-timeout I think you are confusing the ALB session (JSESSIONID cookie if I recall correctly) with the auth session cookie here.

Once again I am no time to validate this but hope that helps :)

like image 137
Tom Avatar answered Oct 19 '22 00:10

Tom