-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add JImmAdmin field to User struct #1101
Add JImmAdmin field to User struct #1101
Conversation
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.. but.. i don't thing renaming user to u was worth it.. it just makes the PR harder to review and brings little to no value - i think calling variable user is better than u..
internal/jimm/access.go
Outdated
@@ -279,7 +279,7 @@ func (auth *JWTGenerator) MakeToken(ctx context.Context, permissionMap map[strin | |||
// to cachedPerms if they exist. If the user does not have any of the desired permissions then an | |||
// error is returned. | |||
// Note that cachedPerms map is modified and returned. | |||
func (j *JIMM) CheckPermission(ctx context.Context, user *openfga.User, cachedPerms map[string]string, desiredPerms map[string]interface{}) (map[string]string, error) { | |||
func (j *JIMM) CheckPermission(ctx context.Context, u *openfga.User, cachedPerms map[string]string, desiredPerms map[string]interface{}) (map[string]string, error) { |
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.
why? saving 4 characters is hardly worth it :)
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.
Well the nice thing about having it consistent is that it's easier to rename now. So I'll change it to user.
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.
I agree renaming u to user makes sense honestly
@@ -29,7 +29,8 @@ func NewUser(u *dbmodel.User, client *OFGAClient) *User { | |||
// to check user's access rights to various resources. | |||
type User struct { | |||
*dbmodel.User | |||
client *OFGAClient | |||
client *OFGAClient | |||
JimmAdmin bool |
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.
Makes sense to me, good job
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, nice work
If you're new to commit signing, there are different ways to set it up: Sign commits with
|
1 similar comment
If you're new to commit signing, there are different ways to set it up: Sign commits with
|
7ec991c
to
679092c
Compare
Description
Slight refactor to make our code more DRY. Instead of repeating checks like the following,
in every facade handler, we instead do the check once when we authenticate the user and pass this information along with the user.
Also made various function signatures more consistent by calling the user variable just
u
. In some places it wasuser
and othersu
.The main issue with this change is that it heavily affects our tests. Tests inside
jujuapi
are largely unaffected because these tests act like integration tests, opening up a client connection as any external client would. Tests inside thejimm
package however are more deeply affected as they call JIMM's handler methods directly and expect the methods to perform an OpenFGA check to determine if the user is a superuser, so these tests required some tweaking to pass the user's admin info from the test itself. Overall I think this is actually a good thing as we can move closer to makingjimm
tests purely unit tests (though some methods still make calls to OpenFGA which we should consider mocking out), and then place integration tests insidejujuapi
.Engineering checklist
Check only items that apply