- Notifications
You must be signed in to change notification settings - Fork1.1k
feat: push GetUsers authorization filter to SQL#8497
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
634f4ca49e893b60c7019400916f946ae673b974b301bfe113733097File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -23,6 +23,7 @@ import ( | ||
| "github.com/coder/coder/coderd/database/db2sdk" | ||
| "github.com/coder/coder/coderd/httpapi" | ||
| "github.com/coder/coder/coderd/rbac" | ||
| "github.com/coder/coder/coderd/rbac/regosql" | ||
| "github.com/coder/coder/coderd/util/slice" | ||
| "github.com/coder/coder/codersdk" | ||
| ) | ||
| @@ -1207,14 +1208,6 @@ func (q *FakeQuerier) GetFileTemplates(_ context.Context, id uuid.UUID) ([]datab | ||
| return rows, nil | ||
| } | ||
| func (q *FakeQuerier) GetGitAuthLink(_ context.Context, arg database.GetGitAuthLinkParams) (database.GitAuthLink, error) { | ||
| if err := validateDatabaseType(arg); err != nil { | ||
| return database.GitAuthLink{}, err | ||
| @@ -5365,76 +5358,37 @@ func (q *FakeQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg database. | ||
| return q.convertToWorkspaceRowsNoLock(ctx, workspaces, int64(beforePageCount)), nil | ||
| } | ||
| func (q *FakeQuerier)GetAuthorizedUsers(ctx context.Context,arg database.GetUsersParams, prepared rbac.PreparedAuthorized) ([]database.GetUsersRow, error) { | ||
| if err := validateDatabaseType(arg); err != nil { | ||
| returnnil, err | ||
| } | ||
| // Call this to match the same function calls as the SQL implementation. | ||
| if prepared != nil { | ||
| _, err := prepared.CompileToSQL(ctx, regosql.ConvertConfig{ | ||
| VariableConverter: regosql.UserConverter(), | ||
| }) | ||
| if err != nil { | ||
| returnnil, err | ||
| } | ||
| } | ||
| users, err := q.GetUsers(ctx, arg) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| q.mutex.RLock() | ||
| defer q.mutex.RUnlock() | ||
| filteredUsers := make([]database.GetUsersRow, 0, len(users)) | ||
| for _, user := range users { | ||
| // If the filter exists, ensure the object is authorized. | ||
| if prepared != nil && prepared.Authorize(ctx, user.RBACObject()) != nil { | ||
| continue | ||
| } | ||
Comment on lines -5392 to -5436 MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. All this is done by the | ||
| filteredUsers = append(filteredUsers, user) | ||
| } | ||
| return filteredUsers, nil | ||
| } | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.