dawdler-client-plug-session
Module Introduction
A module providing a high-performance distributed session implementation.
1. Add the dependency to pom
<groupId>club.dawdler</groupId>
<artifactId>dawdler-client-plug-session</artifactId>
2. identityConfig.properties file description
Used to configure the core parameters of the distributed session.
cookieName=_dawdler_key #Name of the cookie that stores the sessionId
tokenName=token #Name of the sessionId in an http header or http request parameter; defaults to token.
supportHead=false #Whether to support passing the sessionId defined by tokenName in an http header.
supportParam=false #Whether to support passing the sessionId defined by tokenName in an http request parameter.
domain= #Domain of the cookie; generally no need to fill in, the default is fine
path=/ #Path of the cookie; defaults to /
#secure=false #Whether to force the cookie to carry the Secure attribute. When not configured, it follows the request scheme (https requests automatically carry the Secure attribute); once explicitly configured true/false, the configuration takes precedence
maxInactiveInterval=1800 #Session expiration time, in seconds; defaults to 1800 seconds
maxSize=165525 #Maximum number of users online; "online" means logged in and using the session for storage
defense=false #Whether to enable session defense mode (to prevent malicious session creation); once enabled, new sessions created from the same IP exceeding ipLimit cause that IP to be added to the blacklist, and subsequent requests return 403 directly
ipMaxInactiveInterval=1800 #Expiration time of IP counters and the blacklist, in seconds; defaults to 1800 seconds, after which it is automatically unblocked
ipMaxSize=165525 #Maximum number of IPs supported for counting
ipLimit=8 #Maximum number of sessions a single IP may create within the window period. The counter key ip:<ip> is a set (members are the sessionIds of active sessions under that IP); only newly created sessions are written to the set, and subsequent requests of the same session are not counted again; the IP is blacklisted only when the set size exceeds ipLimit
trustedProxyCount=0 #Number of trusted proxy layers, used to locate the real client IP from the tail of X-Forwarded-For (the leading segment can be forged by the client). The default 0 means only the TCP peer address is trusted (the application is directly exposed to the public network); one layer of reverse proxy such as the dawdler gateway/nginx = 1; a load balancer in addition in front of the gateway = 2
defenseis disabled by default: the IP blacklist would also ban normal users of shared egress IPs (carrier NAT / office networks). Please confirm your business pattern before enabling it.In the built-in defaultIdentityConfig.properties inside the jar,
supportHead/supportParamdefault tofalse: when identityConfig.properties is not provided, the sessionId is only read from the cookie, preventing sessionId leakage via URL (Referer / access logs) and session fixation attacks. If you need to pass the token via header/param, explicitly enable it in identityConfig.properties.
3. session-redis.properties file description
The distributed session is implemented based on redis. For the redis client configuration, refer to dawdler-redis-plug
4. Unified configuration center and multi-environment support
Refer to Unified configuration center and multi-environment support