Skip to content

Commit

Permalink
feat: more session settings in ServerConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
kristian authored and s4heid committed Sep 4, 2023
1 parent 57e005c commit 26afd9f
Show file tree
Hide file tree
Showing 5 changed files with 304 additions and 55 deletions.
6 changes: 6 additions & 0 deletions docs/usage/verticles/ServerVerticle.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ property. Some defaults are overridden, and additional config options are provid
| `port` | integer | No | `8080` | Sets the port on which the application server listens. |
| `useAlpn` | boolean | No | `true` | Whether to use application-layer protocol negotiation or not. |
| [`sessionHandling`](#sessionhandling) | string | No | `NONE` | Sets the type of session handling. Must be one of one of: `NONE`, `LOCAL`, or `CLUSTERED`. |
| `sessionTimeout` | integer | No | `30` | Session timeout in minutes. |
| `sessionCookieName` | string | No | `neonbee-web.session` | Sets the name of the session cookie. |
| `sessionCookiePath` | string | No | `/` | Sets the path of the session cookie. |
| `secureSessionCookie` | boolean | No | `false` | Whether to set the `secure` flag of the session cookie. |
| `httpOnlySessionCookie` | boolean | No | `false` | Whether to set the `HttpOnly` flag of the session cookie. |
| `sessionCookieSameSitePolicy` | string | No | `null` | Which `SameSite` policy to use for the cookie. One of: `null`, `NONE`, `STRICT` or `LAX`. |
| `minSessionIdLength` | integer | No | `32` | The minimum length of the session ID. |
| `decompressionSupported` | boolean | No | `true` | Enables server-side decompression of request bodies. |
| `compressionSupported` | boolean | No | `true` | Enables server-side support for compression. |
| `compressionLevel` | integer | No | `true` | Sets the level of compression, if compression is enabled. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@ config:
useAlpn: true
# one of: NONE, LOCAL or CLUSTERED, defaults to NONE
sessionHandling: NONE
# the session timeout in minutes, defaults to 30
sessionTimeout: 30
# the name of the session cookie, defaults to neonbee-web.session
sessionCookieName: neonbee-web.session
# the path of the session cookie, defaults to /
sessionCookiePath: /
# sets whether to set the `secure` flag of the session cookie, defaults to false
secureSessionCookie: false
# sets whether to set the `HttpOnly` flag of the session cookie, defaults to false
httpOnlySessionCookie: false
# one of: null, none, strict, or lax, defaults to null
sessionCookieSameSitePolicy: ~
# the minimum length of the session id, defaults to 32
minSessionIdLength: 32

# sets whether the server should decompress request bodies, defaults to true
decompressionSupported: true
Expand All @@ -39,69 +51,69 @@ config:

# specific endpoint configuration, defaults to the object seen below
endpoints:
# provides a OData V4 compliant endpoint, for accessing entity verticle data
- type: io.neonbee.endpoint.odatav4.ODataV4Endpoint
# enable the OData endpoint, defaults to true
enabled: true
# the base path to map this endpoint to, defaults to /odata/
basePath: /odata/
# endpoint specific authentication chain, defaults to null and using the default authentication chain
authenticationChain: ~
# namespace and service name URI mapping (STRICT, or LOOSE based on CDS)
uriConversion: STRICT
# a block / allow list of verticles to expose via this endpoint (defaults to empty / all entities exposed)
# the value of block / allow must be an array with Strings representing a regexp.
exposedEntities:
block: [any_allow_list_of_regexp_here]
allow: [any_block_list_of_regexp_here]
# provides a OData V4 compliant endpoint, for accessing entity verticle data
- type: io.neonbee.endpoint.odatav4.ODataV4Endpoint
# enable the OData endpoint, defaults to true
enabled: true
# the base path to map this endpoint to, defaults to /odata/
basePath: /odata/
# endpoint specific authentication chain, defaults to null and using the default authentication chain
authenticationChain: ~
# namespace and service name URI mapping (STRICT, or LOOSE based on CDS)
uriConversion: STRICT
# a block / allow list of verticles to expose via this endpoint (defaults to empty / all entities exposed)
# the value of block / allow must be an array with Strings representing a regexp.
exposedEntities:
block: [any_allow_list_of_regexp_here]
allow: [any_block_list_of_regexp_here]

# provides a REST endpoint (JSON, text, binary), for accessing data verticles
- type: io.neonbee.endpoint.raw.RawEndpoint
# enable the raw endpoint, defaults to true
enabled: true
# the base path to map this endpoint to, defaults to /raw/
basePath: /raw/
# endpoint specific authentication chain, defaults to null and using the default authentication chain
authenticationChain: ~
# whether or not to expose hidden verticles, defaults to false
exposeHiddenVerticles: false
# a block / allow list of verticles to expose via this endpoint (defaults to empty all verticles exposed)
# the value of block / allow must be an array with Strings representing a regexp.
exposedVerticles:
block: [any_allow_list_of_regexp_here]
allow: [any_block_list_of_regexp_here]
# provides a REST endpoint (JSON, text, binary), for accessing data verticles
- type: io.neonbee.endpoint.raw.RawEndpoint
# enable the raw endpoint, defaults to true
enabled: true
# the base path to map this endpoint to, defaults to /raw/
basePath: /raw/
# endpoint specific authentication chain, defaults to null and using the default authentication chain
authenticationChain: ~
# whether or not to expose hidden verticles, defaults to false
exposeHiddenVerticles: false
# a block / allow list of verticles to expose via this endpoint (defaults to empty all verticles exposed)
# the value of block / allow must be an array with Strings representing a regexp.
exposedVerticles:
block: [any_allow_list_of_regexp_here]
allow: [any_block_list_of_regexp_here]

# provides an Prometheus scraping endpoint for Micrometer.io metrics
- type: io.neonbee.endpoint.metrics.MetricsEndpoint
# enable the metrics endpoint, defaults to true
enabled: true
# the base path to map this endpoint to, defaults to /metrics/
basePath: /metrics/
# endpoint specific authentication chain, (special case!) defaults to an empty array [] and no authentication required
authenticationChain: []
# provides an Prometheus scraping endpoint for Micrometer.io metrics
- type: io.neonbee.endpoint.metrics.MetricsEndpoint
# enable the metrics endpoint, defaults to true
enabled: true
# the base path to map this endpoint to, defaults to /metrics/
basePath: /metrics/
# endpoint specific authentication chain, (special case!) defaults to an empty array [] and no authentication required
authenticationChain: []

# default authentication chain, defaults to an empty array (no authentication), use:
authenticationChain:
# any of: BASIC, DIGEST, JWT, OAUTH2, REDIRECT, mandatory attribute
- type: string
# ... more authentication handler options (see the specific handler implementations)
- type: string
# ... more authentication handler options (see the specific handler implementations)

# the authentication provider to be set for this handler
provider:
# the authentication provider to be set for this handler# any of: HTDIGEST, HTPASSWD, JDBC, JWT, MONGO, OAUTH2, mandatory attribute
type: string
# ... more authentication provider options (see the specific provider implementations)
# the authentication provider to be set for this handler
provider:
# the authentication provider to be set for this handler# any of: HTDIGEST, HTPASSWD, JDBC, JWT, MONGO, OAUTH2, mandatory attribute
type: string
# ... more authentication provider options (see the specific provider implementations)

# default handler factories. The order of handler factories has to take the priority of the returned handlers into account.
handlerFactories:
- io.neonbee.internal.handler.factories.LoggerHandlerFactory
- io.neonbee.internal.handler.factories.InstanceInfoHandlerFactory
- io.neonbee.internal.handler.factories.CorrelationIdHandlerFactory
- io.neonbee.internal.handler.factories.TimeoutHandlerFactory
- io.neonbee.internal.handler.factories.SessionHandlerFactory
- io.neonbee.internal.handler.factories.CacheControlHandlerFactory
- io.neonbee.internal.handler.factories.CorsHandlerFactory
- io.neonbee.internal.handler.factories.DisallowingFileUploadBodyHandlerFactory
- io.neonbee.internal.handler.factories.LoggerHandlerFactory
- io.neonbee.internal.handler.factories.InstanceInfoHandlerFactory
- io.neonbee.internal.handler.factories.CorrelationIdHandlerFactory
- io.neonbee.internal.handler.factories.TimeoutHandlerFactory
- io.neonbee.internal.handler.factories.SessionHandlerFactory
- io.neonbee.internal.handler.factories.CacheControlHandlerFactory
- io.neonbee.internal.handler.factories.CorsHandlerFactory
- io.neonbee.internal.handler.factories.DisallowingFileUploadBodyHandlerFactory

# configures the CORS handler (Disabled by default)
cors:
Expand All @@ -119,4 +131,4 @@ config:
exposedHeaders: # The exposed headers.
- foobar
maxAgeSeconds: 1337 # Set how long the browser should cache the information.
allowCredentials: false # Set whether credentials are allowed or not.
allowCredentials: false # Set whether credentials are allowed or not.
41 changes: 41 additions & 0 deletions src/generated/java/io/neonbee/config/ServerConfigConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,48 @@ static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, ServerC
obj.setHandlerFactoriesClassNames(list);
}
break;
case "httpOnlySessionCookie":
if (member.getValue() instanceof Boolean) {
obj.setHttpOnlySessionCookie((Boolean) member.getValue());
}
break;
case "minSessionIdLength":
if (member.getValue() instanceof Number) {
obj.setMinSessionIdLength(((Number) member.getValue()).intValue());
}
break;
case "secureSessionCookie":
if (member.getValue() instanceof Boolean) {
obj.setSecureSessionCookie((Boolean) member.getValue());
}
break;
case "sessionCookieName":
if (member.getValue() instanceof String) {
obj.setSessionCookieName((String) member.getValue());
}
break;
case "sessionCookiePath":
if (member.getValue() instanceof String) {
obj.setSessionCookiePath((String) member.getValue());
}
break;
case "sessionCookieSameSitePolicy":
if (member.getValue() instanceof String) {
obj.setSessionCookieSameSitePolicy(
io.vertx.core.http.CookieSameSite.valueOf((String) member.getValue()));
}
break;
case "sessionHandling":
if (member.getValue() instanceof String) {
obj.setSessionHandling(
io.neonbee.config.ServerConfig.SessionHandling.valueOf((String) member.getValue()));
}
break;
case "sessionTimeout":
if (member.getValue() instanceof Number) {
obj.setSessionTimeout(((Number) member.getValue()).intValue());
}
break;
case "timeout":
if (member.getValue() instanceof Number) {
obj.setTimeout(((Number) member.getValue()).intValue());
Expand Down Expand Up @@ -128,12 +159,22 @@ static void toJson(ServerConfig obj, java.util.Map<String, Object> json) {
obj.getHandlerFactoriesClassNames().forEach(item -> array.add(item));
json.put("handlerFactoriesClassNames", array);
}
json.put("httpOnlySessionCookie", obj.isHttpOnlySessionCookie());
json.put("minSessionIdLength", obj.getMinSessionIdLength());
json.put("secureSessionCookie", obj.isSecureSessionCookie());
if (obj.getSessionCookieName() != null) {
json.put("sessionCookieName", obj.getSessionCookieName());
}
if (obj.getSessionCookiePath() != null) {
json.put("sessionCookiePath", obj.getSessionCookiePath());
}
if (obj.getSessionCookieSameSitePolicy() != null) {
json.put("sessionCookieSameSitePolicy", obj.getSessionCookieSameSitePolicy().name());
}
if (obj.getSessionHandling() != null) {
json.put("sessionHandling", obj.getSessionHandling().name());
}
json.put("sessionTimeout", obj.getSessionTimeout());
json.put("timeout", obj.getTimeout());
json.put("timeoutStatusCode", obj.getTimeoutStatusCode());
}
Expand Down
Loading

0 comments on commit 26afd9f

Please sign in to comment.