-
Notifications
You must be signed in to change notification settings - Fork 225
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
FLI-1258: pass org and teams to metadata #3654
Conversation
Signed-off-by: devumesh <[email protected]>
Signed-off-by: devumesh <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3654 +/- ##
==========================================
+ Coverage 64.30% 64.41% +0.10%
==========================================
Files 170 170
Lines 17031 17099 +68
==========================================
+ Hits 10952 11014 +62
- Misses 5396 5400 +4
- Partials 683 685 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution @devumesh!
There are few things which we should address in this PR.
Original code hides some aspects of Github login integration and tests does not cover it. There should be a token with read:org
in scope to fetch user's orgs and teams. Originally the check happens on the configuration level https://github.com/flipt-io/flipt/blob/main/internal/config/authentication.go#L600-L602. Without that getUserOrgs
and getUserTeamsByOrg
api requests will fail and auth flow will be broken for those who don't have that scope in their Flipt configuration.
Also I would like to discuss another thing. I think we should not store all user's orgs and teams, if there is a configuration requirement for specific organizations and/or teams for privacy reasons. wdyt? cc: @markphelps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if err != nil { | ||
return nil, err | ||
} | ||
userOrgs, err := getUserOrgs(ctx, token, apiURL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for another PR: we should consider caching these results in memory for a period of time as now we're doing these REST calls on every request if an org is using GitHub authn and the orgs/team membership do not change nearly that often
Let say, that Flipt configuration has |
Ah that's a good point. I was thinking you were suggesting another config property but I agree with you we should only track the ones configured. |
Hi @erka, correct me If I'm understanding wrong. |
I have a doubt. If the user doesn't configure |
Maybe if your Flipt instance is in internet. But I don't think we can't change it, at least in v1. It started with It would be great to not break auth flow for those first adopters of login with Github. |
Yeah, it's tricky... If there is |
Yeah I guess it should work. If the allowed org is not provided are you suggesting to send all the retrieved orgs for authz? Can you please clarify this. |
Signed-off-by: devumesh <[email protected]>
Signed-off-by: devumesh <[email protected]>
@devumesh Let me explain my vision with examples so you could validate them. 1. no read:org in scopesNo way to get user's organizations and teams, so metadata for organizations and teams should be empty 2. read:org in scopes2.1. no organizations restrictionsFetch user's orgs and teams and add them all to metadata. For example, user has 2.2. with organization restrictionsFetch user's orgs and teams, filter them and include only required organizations which user has. As example, user has 2.3. with organization and team restrictionsSame as 2.2 but filter user's teams as well. WDYT? |
Hey @erka , thanks. I have made changes as you mentioned. But I have made a mistake where instead of passing orgs |
Signed-off-by: devumesh <[email protected]>
Signed-off-by: devumesh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm @devumesh !! just one minor style request around instantiating the err
var instead of reusing one when doing if err = x; err != nil
@all-contributors please add @devumesh for code |
@devumesh already contributed before to code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Co-authored-by: Mark Phelps <[email protected]>
Hi @markphelps, thank you. committed your suggestion. Please review. |
Approach:
if orgs > 0
.if allowed_teams > 0
.io.flipt.auth.github.orgs
.{org1: [list of teams],org2: [list of teams]}
and store inio.flipt.auth.github.teams
.closes #3435