Sessions in Kong Manager

When a user logs in to Kong Manager with their credentials, the Sessions Plugin will create a session cookie. The cookie is used for all subsequent requests and is valid to authenticate the user. The session has a limited duration and renews at a configurable interval, which helps prevent an attacker from obtaining and using a stale cookie after the session has ended.

The Session configuration is secure by default, which may require alteration if using HTTP or different domains for the Admin API and Kong Manager. Even if an attacker were to obtain a stale cookie, it would not benefit them since the cookie is encrypted. The encrypted session data may be stored either in Kong or the cookie itself.

Configuration the Sessions plugin for Kong Manager

To enable sessions authentication, configure the following:

  1. enforce_rbac = on
  2. admin_gui_auth = <set to desired auth type>
  3. admin_gui_session_conf = {
  4. "secret":"<SET_SECRET>",
  5. "cookie_name":"<SET_COOKIE_NAME>",
  6. "storage":"<SET_STORAGE>",
  7. "rolling_timeout":<NUMBER_OF_SECONDS_UNTIL_RENEWAL>,
  8. "cookie_secure":<SET_DEPENDING_ON_PROTOCOL>
  9. "cookie_same_site":"<SET_DEPENDING_ON_DOMAIN>"
  10. }
AttributeDescription
cookie_nameA name for the cookie.
For example, “cookie_name”:”kong_cookie”
secretThe secret used in keyed HMAC generation. Although the Session plugin’s default is a random string, the secret must be manually set for use with Kong Manager since it must be the same across all Kong workers/nodes.
storageThe location where session data is stored.
The default value is cookie. It may be more secure if set to kong, since access to the database would be required.
rolling_timeoutSpecifies, in seconds, how long the session can be used until it needs to be renewed.
The default value is 3600.
cookie_secureApplies the Secure directive so that the cookie may be sent to the server only with an encrypted request over the HTTPS protocol. See Session Security for exceptions.
The default value is true.
cookie_same_siteDetermines whether and how a cookie may be sent with cross-site requests. See Session Security for exceptions.
The default value is strict.

Important: The following properties must not be altered from default for use with Kong Manager:

  • logout_methods
  • logout_query_arg
  • logout_post_arg

For detailed descriptions of each configuration property, learn more in the Session plugin documentation.

Session security

The Session configuration is secure by default, so the cookie uses the Secure, HttpOnly, and SameSite directives.

The following properties must be altered depending on the protocol and domains in use:

  • If using HTTP instead of HTTPS: "cookie_secure": false
  • If using different domains for the Admin API and Kong Manager: "cookie_same_site": "Lax"

Important: Sessions are not invalidated when a user logs out if "storage": "cookie" (the default) is used. In that case, the cookie is deleted client-side. Only when session data is stored server-side with "storage": "kong" set is the session actively invalidated.

Example configurations

If using HTTPS and hosting Kong Manager and the Admin API from the same domain, the following configuration could be used for Basic Auth:

  1. enforce_rbac = on
  2. admin_gui_auth = basic-auth
  3. admin_gui_session_conf = {
  4. "cookie_name":"$4m04$",
  5. "secret":"change-this-secret",
  6. "storage":"kong"
  7. }

In testing, if using HTTP, the following configuration could be used instead:

  1. enforce_rbac = on
  2. admin_gui_auth = basic-auth
  3. admin_gui_session_conf = {
  4. "cookie_name":"04tm34l",
  5. "secret":"change-this-secret",
  6. "storage":"kong",
  7. "cookie_secure":false
  8. }