Skip to content

Conversation

@maros2710
Copy link

@maros2710 maros2710 commented Jul 5, 2023

  • Breaking change? (if so, please describe the impact and migration path for existing application instances)

What changes did you make? (Give an overview)
Closes #2751

Added github teams support. (see #2751)
Now you can set up github team in rbac configuration like this:

- provider: oauth_github
  type: team  
  value: "provectus/memelords" #{organization}/{team}

Is there anything you'd like reviewers to focus on?
I am not very good at reactor, so maybe look at my reactive pipelines, please :)

How Has This Been Tested? (put an "x" (case-sensitive!) next to an item)

  • No need to
  • Manually (please, describe, if necessary)
  • Unit checks
  • Integration checks
  • Covered by existing automation

Checklist (put an "x" (case-sensitive!) next to all the items, otherwise the build will fail)

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (e.g. ENVIRONMENT VARIABLES)
  • My changes generate no new warnings (e.g. Sonar is happy)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged

Check out Contributing and Code of Conduct

image

@maros2710 maros2710 requested a review from a team as a code owner July 5, 2023 11:19
Copy link
Contributor

@Haarolean Haarolean left a comment

Choose a reason for hiding this comment

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

Hi, and thanks for your contribution. Please take a look at the comment I've left.
Also, please refer to our contributing guide and follow one for the future contributions (I've been working on this issue already thus the issue was assigned to me), having you to comment on the issue to grab it beforehand would be nice.

String[] organizationAndTeam = orgTeam.split("/");
String org = organizationAndTeam[0];
String team = organizationAndTeam[1];
WebClient wc = WebClient.create(
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we can refrain from creating a webclient for every each of the requests

Copy link
Author

Choose a reason for hiding this comment

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

I have added git gitHubApiUri property to OAuthProperties.OAuth2Provider that is later used as base GitHub api URI

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need such a property as it should be fetched via OpenID provider configuration request.
You can fetch it via req.getClientRegistration().getProviderDetails().getUserInfoEndpoint().getUri()

return teams
.doOnNext(t -> {
if (t.getRight() instanceof Map) {
Map<String, String> response = (Map<String, String>) t.getRight();
Copy link
Contributor

Choose a reason for hiding this comment

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

We'd like to see a cleaner approach here, let's say this:

  1. we filter the roles we have and if there are no subjects matching github teams, we can skip teams fetching altogether
  2. the same applies to organizations, if none are present in roles, we don't have to query organizations either

Copy link
Author

Choose a reason for hiding this comment

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

I am not sure, if I understand, can you explain a little bit more please? Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

@maros2710

  1. don't fetch user teams if there are no RBAC subjects with "oauth_github/team" present, the same applies to organizations
  2. don't use pairs, concat three lists, each one for roles by orgs, roles by teams and roles by username.

@Haarolean Haarolean added type/enhancement En enhancement to an already existing feature scope/backend labels Jul 5, 2023
Cleanup of the code
Reuse of WebClient to get GitHub teams info
@darkLord19
Copy link

@maros2710 are you still interested in completing this or can I try resolving the review comments?

@Haarolean
Copy link
Contributor

Closing in favor of #4093

@Haarolean Haarolean closed this Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/backend type/enhancement En enhancement to an already existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RBAC: Support github teams

4 participants