Repository: provectus/kafka-ui
Issue: RBAC : Github Organizations could be more than 30
Labels: type/bug
good first issue
scope/backend
status/accepted
severity/low
area/rbac

### Issue submitter TODO list

- [X] I've searched for an already existing issues [here](https://github.com/provectus/kafka-ui/issues)
- [X] I'm running a supported version of the application which is listed [here](https://github.com/provectus/kafka-ui/blob/master/SECURITY.md) and the feature is not present there

### Is your proposal related to a problem?

I think organizations for authenticated user can be more than 30.

https://github.com/provectus/kafka-ui/blob/ab9d0e2b3f6fc54344ecb1912d974f139020ca48/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/rbac/extractor/GithubAuthorityExtractor.java#L84-L94

https://docs.github.com/en/enterprise-server@3.6/rest/orgs/orgs#list-organizations-for-the-authenticated-user
It response only 30 organizations if you request without `per_page` parameter.

So, if i use 31st organization for rbac it will not work.

### Describe the feature you're interested in

I want RBAC with `oauth_github` provider and `organization` type works even if there are more than 30 organizations for authenticated user.

### Describe alternatives you've considered

_No response_

### Version you're running

902f11a

### Additional context

_No response_

Issue comments:
Hello there seono! 👋

Thank you and congratulations 🎉 for opening your very first issue in this project! 💖

In case you want to claim this issue, please comment down below! We will try to get back to you as soon as we can. 👀
Hi, has this happened to you?

With over ten years of using github I don't remember encountering a single user with over than 15 organizations, that's half of 30.

Unless there are users affected by this already, this is a low priority issue.
@Haarolean thanks for reply.

I agree with you that a single user has under 15 organizations in github.
It happened to me in my company's github enterprise.

So if you don't mind, can i try this issue? I want fix this myself.


Pull request review comments:
please add comment that it is a max value for github api / make a constant with descriptive name
@iliax thanks for review!
I make constant and add comment.
please let me know if comment is too summarized.

Patch that resolved the issue:
diff --git a/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/rbac/extractor/GithubAuthorityExtractor.java b/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/rbac/extractor/GithubAuthorityExtractor.java
index 3cc33035e88..654654a05dd 100644
--- a/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/rbac/extractor/GithubAuthorityExtractor.java
+++ b/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/rbac/extractor/GithubAuthorityExtractor.java
@@ -28,6 +28,8 @@ public class GithubAuthorityExtractor implements ProviderAuthorityExtractor {
   private static final String ORGANIZATION_NAME = "login";
   private static final String GITHUB_ACCEPT_HEADER = "application/vnd.github+json";
   private static final String DUMMY = "dummy";
+  // The number of results (max 100) per page of list organizations for authenticated user.
+  private static final Integer ORGANIZATIONS_PER_PAGE = 100;
 
   @Override
   public boolean isApplicable(String provider, Map<String, String> customParams) {
@@ -83,7 +85,9 @@ public Mono<Set<String>> extract(AccessControlService acs, Object value, Map<Str
 
     final Mono<List<Map<String, Object>>> userOrganizations = webClient
         .get()
-        .uri("/orgs")
+        .uri(uriBuilder -> uriBuilder.path("/orgs")
+            .queryParam("per_page", ORGANIZATIONS_PER_PAGE)
+            .build())
         .headers(headers -> {
           headers.set(HttpHeaders.ACCEPT, GITHUB_ACCEPT_HEADER);
           OAuth2UserRequest request = (OAuth2UserRequest) additionalParams.get("request");


Test patch: