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

Improve JWT format with namespaces grouping #500

Merged
merged 5 commits into from
Jan 14, 2025

Conversation

ThomasCAI-mlv
Copy link
Collaborator

@ThomasCAI-mlv ThomasCAI-mlv commented Jan 7, 2025

This PR is about reducing the size of the JWT (access_token) generated by the /login endpoint, which is then used to authenticate in other endpoints. This would heavily reduce the risk of reaching the http.client.max-content-length limit in the future when the namespaces number increases, and have better performance in the logging process.

Example of the current JWT roleBindings format:

"roleBindings": [ { "namespace": "namespace1", "verbs": [ "GET", "POST", "PUT", "DELETE" ], "resourceTypes": [ "schemas", "schemas/config", "topics", "topics/delete-records" ] }, { "namespace": "namespace2", "verbs": [ "GET", "POST", "PUT", "DELETE" ], "resourceTypes": [ "schemas", "schemas/config", "topics", "topics/delete-records" ] }, { "namespace": "namespace3", "verbs": [ "GET", "POST", "PUT", "DELETE" ], "resourceTypes": [ "schemas", "schemas/config", "topics", "topics/delete-records" ] } ]

This PR changes the format of the JWT so the namespaces are grouped if they have the same verbs and resourceTypes fields.
The previous example becomes:

"roleBindings": [ { "namespaces": [ "namespace1", "namespace2", "namespace3" ], "verbs": [ "GET", "POST", "PUT", "DELETE" ], "resourceTypes": [ "schemas", "schemas/config", "topics", "topics/delete-records" ] } ]

The string namespace field is replaced by a list of string namespaces field.

This PR is linked with this kafkactl PR.

@ThomasCAI-mlv ThomasCAI-mlv added the enhancement This issue or pull request improves a feature label Jan 7, 2025
@ThomasCAI-mlv ThomasCAI-mlv self-assigned this Jan 7, 2025
Copy link
Collaborator

@loicgreffier loicgreffier left a comment

Choose a reason for hiding this comment

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

@ThomasCAI-mlv Everything LGTM. Tests are good as well. I pushed an additional commit to remove the RoleBindingRepository roleBindingRepository; which was unused in ResourceBasedSecurityRule.

@loicgreffier loicgreffier merged commit 319cf6b into master Jan 14, 2025
4 checks passed
@loicgreffier loicgreffier deleted the optimize-jwt-content-groupby branch January 14, 2025 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue or pull request improves a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Too big cookie issue when using kafkactl with too much namespaces access
3 participants