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

Avoid duplicate everyone check #1327

Merged
merged 3 commits into from
Aug 28, 2024
Merged

Conversation

kian99
Copy link
Contributor

@kian99 kian99 commented Aug 26, 2024

Description

I noticed in many places we were checking a user's access to a resource and if they had no access, then checking the "everyone" user's access. This is not necessary because when the "everyone" user is granted access to a resource, OpenFGA transparently handles such cases. I.e. If "everyone" has access to a model, and we check whether Alice has access to that model, although she doesn't have a direct relation to the model, the check will return the "everyone" user's access level.

I also created a utility method on jimm to return the "everyone" user without requiring duplicated setup.

See https://openfga.dev/docs/modeling/public-access for more info.

@kian99 kian99 requested a review from a team as a code owner August 26, 2024 10:28
@kian99 kian99 changed the title Cloud default follow up Avoid duplicate everyone check Aug 27, 2024
alesstimec
alesstimec previously approved these changes Aug 27, 2024
)

/**
* Authorisation utilities
**/

// EveryoneUser is a convenience method to retrieve the "everyone" user
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: EveryoneIdentity?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bit torn on this, I think EveryoneUser conveys a better understanding when you read it.

ale8k
ale8k previously approved these changes Aug 27, 2024
internal/jimm/utils.go Outdated Show resolved Hide resolved
@kian99 kian99 dismissed stale reviews from ale8k and alesstimec via 1645376 August 28, 2024 09:55
Copy link
Contributor

@ale8k ale8k left a comment

Choose a reason for hiding this comment

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

ty for changing

@kian99 kian99 merged commit 6c1d24d into canonical:v3 Aug 28, 2024
4 checks passed
@kian99 kian99 deleted the cloud-default-follow-up branch August 28, 2024 15:03
kian99 added a commit to kian99/jimm that referenced this pull request Sep 3, 2024
* avoid duplicate everyone checks

* make method not exported
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants