Skip to content

Commit

Permalink
fix: make defaultauthz more permissive: Allow reviewers to write and …
Browse files Browse the repository at this point in the history
…standalone models are write-all
  • Loading branch information
Tethik committed Oct 9, 2023
1 parent dabbf6f commit 1d2752e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
14 changes: 11 additions & 3 deletions core/src/auth/DefaultAuthzProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export class DefaultAuthzProvider implements AuthzProvider {
* Reviewers may review any model
*/
if (user.roles.find((r) => r === Role.Reviewer)) {
permissions.push(Permission.Read, Permission.Review);
/**
* TODO: give write permission only if reviewer is assigned to the model.
*/
permissions.push(Permission.Read, Permission.Write, Permission.Review);
}

/**
Expand Down Expand Up @@ -59,14 +62,19 @@ export class DefaultAuthzProvider implements AuthzProvider {

if (user.roles.find((r) => r === Role.Admin)) return AllPermissions;

/**
* Standalone models are mainly used for training. To avoid authz issues here we allow most things
* by most users. Ideally here there should be some sharing system.
*/

const permissions: Permission[] = [];

if (user.roles.find((r) => r === Role.Reviewer)) {
permissions.push(Permission.Read, Permission.Review);
permissions.push(Permission.Read, Permission.Review, Permission.Write);
}

if (user.roles.find((r) => r === Role.User)) {
permissions.push(Permission.Read);
permissions.push(Permission.Read, Permission.Write);
}

if (model.createdBy === user.sub) {
Expand Down
5 changes: 2 additions & 3 deletions plugins/github/src/GithubAuthzProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@ export class GithubAuthzProvider implements AuthzProvider {
user: UserToken
): Promise<Permission[]> {
if (model.createdBy === user.sub) {
return AllPermissions;
} else {
return [Permission.Read];
return [Permission.Read, Permission.Write, Permission.Delete];
}
return [Permission.Read];
}
key: string = "passthrough";
}

0 comments on commit 1d2752e

Please sign in to comment.