Make sudo access managed via IAM rather than group checkmark
This commit is contained in:
@@ -207,14 +207,25 @@ class User extends AuthUser {
|
||||
return groups.some(group => group.grants_sudo)
|
||||
}
|
||||
|
||||
async to_sudo() {
|
||||
async to_sudo(iam_targets = []) {
|
||||
const Policy = this.models.get('iam:Policy')
|
||||
const granted = []
|
||||
for ( const target of iam_targets ) {
|
||||
if ( await Policy.check_user_access(this, target, 'sudo') ) {
|
||||
granted.push(target)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
objectClass: ['sudoRole'],
|
||||
cn: `sudo_${this.uid.toLowerCase()}`,
|
||||
sudoUser: this.uid.toLowerCase(),
|
||||
sudoHost: 'ALL',
|
||||
sudoRunAs: 'ALL',
|
||||
sudoCommand: 'ALL',
|
||||
...(granted.length ? {
|
||||
iamtarget: granted,
|
||||
sudoHost: 'ALL',
|
||||
sudoRunAs: 'ALL',
|
||||
sudoCommand: 'ALL',
|
||||
} : {})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user