| 
									
										
										
										
											2023-02-14 13:36:47 -05:00
										 |  |  | package auth;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import com.typesafe.config.Config;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public class CookieConfigs {
 | 
					
						
							|  |  |  |   public static final String SESSION_TTL_CONFIG_PATH = "auth.session.ttlInHours";
 | 
					
						
							|  |  |  |   public static final Integer DEFAULT_SESSION_TTL_HOURS = 720;
 | 
					
						
							|  |  |  |   public static final String AUTH_COOKIE_SAME_SITE = "play.http.session.sameSite";
 | 
					
						
							|  |  |  |   public static final String DEFAULT_AUTH_COOKIE_SAME_SITE = "LAX";
 | 
					
						
							|  |  |  |   public static final String AUTH_COOKIE_SECURE = "play.http.session.secure";
 | 
					
						
							|  |  |  |   public static final boolean DEFAULT_AUTH_COOKIE_SECURE = false;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-28 09:05:16 -05:00
										 |  |  |   private final int ttlInHours;
 | 
					
						
							|  |  |  |   private final String authCookieSameSite;
 | 
					
						
							|  |  |  |   private final boolean authCookieSecure;
 | 
					
						
							| 
									
										
										
										
											2023-02-14 13:36:47 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   public CookieConfigs(final Config configs) {
 | 
					
						
							| 
									
										
										
										
											2024-10-28 09:05:16 -05:00
										 |  |  |     ttlInHours =
 | 
					
						
							| 
									
										
										
										
											2023-12-06 11:02:42 +05:30
										 |  |  |         configs.hasPath(SESSION_TTL_CONFIG_PATH)
 | 
					
						
							|  |  |  |             ? configs.getInt(SESSION_TTL_CONFIG_PATH)
 | 
					
						
							|  |  |  |             : DEFAULT_SESSION_TTL_HOURS;
 | 
					
						
							| 
									
										
										
										
											2024-10-28 09:05:16 -05:00
										 |  |  |     authCookieSameSite =
 | 
					
						
							| 
									
										
										
										
											2023-12-06 11:02:42 +05:30
										 |  |  |         configs.hasPath(AUTH_COOKIE_SAME_SITE)
 | 
					
						
							|  |  |  |             ? configs.getString(AUTH_COOKIE_SAME_SITE)
 | 
					
						
							|  |  |  |             : DEFAULT_AUTH_COOKIE_SAME_SITE;
 | 
					
						
							| 
									
										
										
										
											2024-10-28 09:05:16 -05:00
										 |  |  |     authCookieSecure =
 | 
					
						
							| 
									
										
										
										
											2023-12-06 11:02:42 +05:30
										 |  |  |         configs.hasPath(AUTH_COOKIE_SECURE)
 | 
					
						
							|  |  |  |             ? configs.getBoolean(AUTH_COOKIE_SECURE)
 | 
					
						
							|  |  |  |             : DEFAULT_AUTH_COOKIE_SECURE;
 | 
					
						
							| 
									
										
										
										
											2023-02-14 13:36:47 -05:00
										 |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public int getTtlInHours() {
 | 
					
						
							| 
									
										
										
										
											2024-10-28 09:05:16 -05:00
										 |  |  |     return ttlInHours;
 | 
					
						
							| 
									
										
										
										
											2023-02-14 13:36:47 -05:00
										 |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public String getAuthCookieSameSite() {
 | 
					
						
							| 
									
										
										
										
											2024-10-28 09:05:16 -05:00
										 |  |  |     return authCookieSameSite;
 | 
					
						
							| 
									
										
										
										
											2023-02-14 13:36:47 -05:00
										 |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public boolean getAuthCookieSecure() {
 | 
					
						
							| 
									
										
										
										
											2024-10-28 09:05:16 -05:00
										 |  |  |     return authCookieSecure;
 | 
					
						
							| 
									
										
										
										
											2023-02-14 13:36:47 -05:00
										 |  |  |   }
 | 
					
						
							|  |  |  | }
 |