-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
AuthZ: Extend /api/search to work with self-contained permissions #70749
Conversation
* clean up, changes to the search
* Refactor and simplify 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.
Some tiny comments about tests, but I also have questions about the query logic. Let's catch up at some point to talk it through.
hi @mgyongyosi |
@papagian Correct, but based on @kalleep's feedback, I'm gonna change the |
b97ab89
to
0ba0f85
Compare
return result | ||
} | ||
|
||
func parseArguments(actions []string, user *user.SignedInUser, scopePrefix string) []interface{} { |
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 think this logic would list all the dashboards that user has any of the required permissions on, while the old logic was listing dashboards that user has all of the required permissions on. Or am I misunderstanding something?
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.
Thanks! I investigated this and you are right! I pushed a fix + added tests for this scenario!
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 👍
I left a couple of comments/suggestions, the cyclomatic complexity of the buildClause
function is what worries me most. I'd consider splitting 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.
LGTM 👍
I left a couple of comments/suggestions, the cyclomatic complexity of the buildClause
function is what worries me most. I'd consider splitting it 🤔
Co-authored-by: Gabriel MABILLE <[email protected]>
Co-authored-by: Gabriel MABILLE <[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.
Nice, looks good to me now! The permission filter clause function is pretty mahoosive now, so I think it would be good to try to refactor it. But let's leave that for a separate PR.
@@ -184,7 +184,7 @@ func (s *UserSync) upsertAuthConnection(ctx context.Context, userID int64, ident | |||
if createConnection { |
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.
Hey @mgyongyosi will this change start to create user_auth entries for basic auth and api key auth? This might be problematic but not an active issue.
Most important would be for sessions to not set auth modules as they should take the 'last authenticated' method
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.
Nope, because the SyncHook
is only executed when the ClientParams.SyncUser
is set to true
and it's set to true for only external auth.
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.
works for me, thanks for the confirmation
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.
…0749) * Search sql filter draft, unfinished * Search works for empty roles * Add current AuthModule to SignedInUser * clean up, changes to the search * Use constant prefixes * Change AuthModule to AuthenticatedBy * Add tests for using the permissions from the SignedInUser * Refactor and simplify code * Fix sql generation for pg and mysql * Fixes, clean up * Add test for empty permission list * Fix * Fix any vs all in case of edit permission * Update pkg/services/authn/authn.go Co-authored-by: Gabriel MABILLE <[email protected]> * Update pkg/services/sqlstore/permissions/dashboard_test.go Co-authored-by: Gabriel MABILLE <[email protected]> * Fixes, changes based on the review --------- Co-authored-by: Gabriel MABILLE <[email protected]>
What is this feature?
This PR extends the
accessControlDashboardPermissionFilter
(used by the/api/search
endpoint) to be capable of handling users authenticated by the Extended JWT client (in which the SignedInUser's permissions are populated from theentitlement
claim of the access token) and these changes make sure that the search result only contains dashboards and folders that the SignedInUser has access to.Besides, this PR adds a new field to the
SignedInUser
calledAuthenticatedBy
which stores the name of the Auth Client that authenticated the current user.Why do we need this feature?
The dashboard filters should handle the case when the permissions are only set in the
SignedInUser
'sPermissions
field and this field is the source of truth for the users' permission which is the case for Extended JWT Client.Used by the experimental external service communication feature (which is using OAuth2 in the background).
Who is this feature for?
[Add information on what kind of user the feature is for.]
Which issue(s) does this PR fix?:
Fixes #
Special notes for your reviewer:
If the user has the following Permissions:
Then the generated SQL will be
nestedFolders = on
nestedFolders = off
Please check that: