-
Notifications
You must be signed in to change notification settings - Fork 887
feat: Dbauthz is now default, remove out of experimental #6650
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
Conversation
client, _, api := coderdtest.NewWithAPI(t, &coderdtest.Options{IncludeProvisionerDaemon: true}) | ||
user := coderdtest.CreateFirstUser(t, client) | ||
authz := coderdtest.AssertRBAC(t, api, client) |
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.
See this unit test to see how to asset an rbac action was checked.
This is a very basic check on 1 GET
, but shows how you can assert certain rbac checks are run with the given client as the subject.
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.
This is a nice feature to have, but given that it essentially duplicates what we already codify in our authz_querier, we should probably use it sparingly.
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.
Blocked by #6654
// RBACAsserter is a helper for asserting that the correct RBAC checks are | ||
// performed. This struct is tied to a given user, and only authorizes calls | ||
// for this user are checked. | ||
type RBACAsserter struct { |
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.
This is really nice to have integrated into coderdtest
.
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.
Looking good so far; just one comment where we should probably add a separate unit test for the case of an admin resetting another user's password.
There is a unit test already 👍 |
coderd/coderdtest/authorize.go
Outdated
func caller(skip int) string { | ||
pc, file, line, ok := runtime.Caller(skip + 1) | ||
i := strings.Index(file, "coder") | ||
if i >= 0 { | ||
file = file[i:] | ||
} | ||
str := fmt.Sprintf("%s:%d", file, line) | ||
if ok { | ||
f := runtime.FuncForPC(pc) | ||
filepath.Base(f.Name()) | ||
str += " | " + filepath.Base(f.Name()) | ||
} | ||
return str | ||
} |
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.
💪
What this does
Almost all RBAC checks happen in dbauthz layer now.
Unit tests
I removed
AuthorizeAllEndpoints
, it was flawed anyway.A new method of doing rbac assertions was added if you want to check this in a route test. This is no longer required though as
dbauthz
enforces rbac checks. This exists for edge cases or debugging. Tests are optional similar to how we check audit log entries.