Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use deflate to compress authentication header payload in Dashboard cookie #1338

Closed

Conversation

nibix
Copy link

@nibix nibix commented Feb 21, 2023

Description

First shot at a compression-based solution for #1311 . More a RFC on the approach than a final pull request. Covers so far only SAML. OIDC will come when we have the concept straight.

Uses deflate compression to compress the main payload of the Dashboards security cookie when SAML auth is active. This might help with issues in environments where users have big amounts of roles or attributes. Such users can have trouble with logging into Dashboards because the security cookie - which carries this information encoded in a JWT - gets too big.

The deflated value is written into the attribute authHeaderValueCompressed inside the cookie. This allows us to tell new cookies apart from cookies written with an earlier version and to support both.

Issues and Limitations

  • Obviously, this only moves the bar at which users might get issues.
  • By default, dashboards (and the underlying Hapi) manage the session storage as follows: First, the payload is JSON encoded. Then, the payload is encrypted using Iron encryption and base64 encoded. As the deflate output is binary, we need to encode it to base64 in order to properly represent it in JSON. However, this again blows the payload size up a bit which we just compressed before.
  • We still need some example payloads to verify the actual effectiveness of this change.

Category

  • Bug fix

Why these changes are required?

Allow users with many roles to authenticate with SAML in Dashboards.

What is the old behavior before changes and new behavior after changes?

Such users could not log in into Dashboards.

Issues Resolved

Testing

  • Unit testing
  • We still need some sample payloads to verify the effectiveness

Check List

  • New functionality includes testing
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…okie

Signed-off-by: Nils Bandener <git@bndnr.de>
@cwperks
Copy link
Member

cwperks commented Feb 22, 2023

@nibix this approach looks promising to me. The example of compressing 14kb -> a little over 4kb sounds like it will relieve some of the pain for user's but not solve all cases.

@stephen-crawford
Copy link
Contributor

Hi @nibix, thank you for writing up this draft. As Craig mentioned this looks like a good start. Is there anything that will need to be done in order to checksum/verify the final cookie against the original? Is it possible to do this without having to transfer the uncompressed cookie for comparison? Or do we simply need to assume that the cookie is correct when it arrives? I don't know if this is a concern with this type of implementation but wanted to ask.

Copy link
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, much closer to our end state! I think we might be able to have the auth header span multiple cookies to provide headroom.

While in draft, I would recommend documenting / stubbing out what kinds of scenario tests we should create.

@@ -104,7 +110,7 @@ export class SamlAuthentication extends AuthenticationType {
cookie.authType === AuthType.SAML &&
cookie.username &&
cookie.expiryTime &&
cookie.credentials?.authHeaderValue
(cookie.credentials?.authHeaderValue || cookie.credentials?.authHeaderValueCompressed)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you think about inserting a cookie splitter that could provide head room of these requests?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be an option, but we cannot do this inside this code. From this code, we can only write exactly one cookie.

@nibix
Copy link
Author

nibix commented Feb 22, 2023

Or do we simply need to assume that the cookie is correct when it arrives?

I believe we should just assume that the cookie is correct when it is arrives. Additionally, the deflate compression algorithm already stores a checksum at the end of the data, thus we already have a certain validation.

Additionally, of course, the JWT also has a signature which would become invalid when something goes wrong in the round trip.

@nibix
Copy link
Author

nibix commented Apr 5, 2023

Superseded by #1352

@nibix nibix closed this Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants