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

rbac: casbin: adjust model to use keyMatch5 #6290

Merged
merged 19 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
stop AuthZ to override input
  • Loading branch information
moogacs committed Nov 12, 2024
commit fe60322c3127ddc15e639057ed5e181f6216fd93
9 changes: 6 additions & 3 deletions usecases/auth/authorization/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 92,9 @@ func Collections(classes ...string) []string {
resources := make([]string, len(classes))
for idx := range classes {
if classes[idx] == "" {
classes[idx] = "*"
resources[idx] = "collections/*"
} else {
resources[idx] = fmt.Sprintf("collections/%s/*", classes[idx])
}
resources[idx] = fmt.Sprintf("collections/%s/*", classes[idx])
moogacs marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down Expand Up @@ -124,9 126,10 @@ func Shards(class string, shards ...string) []string {
resources := make([]string, len(shards))
for idx := range shards {
if shards[idx] == "" {
shards[idx] = "*"
resources[idx] = fmt.Sprintf("collections/%s/shards/*/*", class)
} else {
resources[idx] = fmt.Sprintf("collections/%s/shards/%s/*", class, shards[idx])
}
resources[idx] = fmt.Sprintf("collections/%s/shards/%s/*", class, shards[idx])
}

return resources
Expand Down
8 changes: 4 additions & 4 deletions usecases/schema/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 199,16 @@ func (h *Handler) UpdateTenants(ctx context.Context, principal *models.Principal
//
// Class must exist and has partitioning enabled
func (h *Handler) DeleteTenants(ctx context.Context, principal *models.Principal, class string, tenants []string) error {
if err := h.Authorizer.Authorize(principal, authorization.DELETE, authorization.Shards(class, tenants...)...); err != nil {
return err
}

for i, name := range tenants {
if name == "" {
return fmt.Errorf("empty tenant name at index %d", i)
}
}

if err := h.Authorizer.Authorize(principal, authorization.DELETE, authorization.Shards(class, tenants...)...); err != nil {
return err
}

req := api.DeleteTenantsRequest{
Tenants: tenants,
}
Expand Down
Loading