-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: Implement ACLs access based on ACLs (#9835)
Adds restrictions to everything within the ACLs (and nspaces) area based on your ACLs (including readonly views etc.)
- Loading branch information
Showing
33 changed files
with
339 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import BaseAbility from './base'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default class AuthMethodAbility extends BaseAbility { | ||
@service('env') env; | ||
|
||
resource = 'acl'; | ||
segmented = false; | ||
|
||
get canRead() { | ||
return this.env.var('CONSUL_ACLS_ENABLED') && super.canRead; | ||
} | ||
|
||
get canCreate() { | ||
return this.env.var('CONSUL_ACLS_ENABLED') && super.canCreate; | ||
} | ||
|
||
get canDelete() { | ||
return this.env.var('CONSUL_ACLS_ENABLED') && super.canDelete; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import BaseAbility from './base'; | ||
import { inject as service } from '@ember/service'; | ||
import { typeOf } from 'consul-ui/helpers/policy/typeof'; | ||
|
||
export default class PolicyAbility extends BaseAbility { | ||
@service('env') env; | ||
|
||
resource = 'acl'; | ||
segmented = false; | ||
|
||
get canRead() { | ||
return this.env.var('CONSUL_ACLS_ENABLED') && super.canRead; | ||
} | ||
|
||
get canWrite() { | ||
return ( | ||
this.env.var('CONSUL_ACLS_ENABLED') && | ||
(typeof this.item === 'undefined' || typeOf([this.item]) !== 'policy-management') && | ||
super.canRead | ||
); | ||
} | ||
|
||
get canCreate() { | ||
return this.env.var('CONSUL_ACLS_ENABLED') && super.canCreate; | ||
} | ||
|
||
get canDelete() { | ||
return ( | ||
this.env.var('CONSUL_ACLS_ENABLED') && | ||
(typeof this.item === 'undefined' || typeOf([this.item]) !== 'policy-management') && | ||
super.canDelete | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import BaseAbility from './base'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default class RoleAbility extends BaseAbility { | ||
@service('env') env; | ||
|
||
resource = 'acl'; | ||
segmented = false; | ||
|
||
get canRead() { | ||
return this.env.var('CONSUL_ACLS_ENABLED') && super.canRead; | ||
} | ||
|
||
get canCreate() { | ||
return this.env.var('CONSUL_ACLS_ENABLED') && super.canCreate; | ||
} | ||
|
||
get canDelete() { | ||
return this.env.var('CONSUL_ACLS_ENABLED') && super.canDelete; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import BaseAbility from './base'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
import { isLegacy } from 'consul-ui/helpers/token/is-legacy'; | ||
import { isAnonymous } from 'consul-ui/helpers/token/is-anonymous'; | ||
|
||
export default class TokenAbility extends BaseAbility { | ||
@service('env') env; | ||
|
||
resource = 'acl'; | ||
segmented = false; | ||
|
||
get canRead() { | ||
return this.env.var('CONSUL_ACLS_ENABLED') && super.canRead; | ||
} | ||
|
||
get canCreate() { | ||
return this.env.var('CONSUL_ACLS_ENABLED') && super.canCreate; | ||
} | ||
|
||
get canDelete() { | ||
return ( | ||
this.env.var('CONSUL_ACLS_ENABLED') && | ||
!isAnonymous([this.item]) && | ||
this.item.AccessorID !== this.token.AccessorID && | ||
super.canDelete | ||
); | ||
} | ||
|
||
get canDuplicate() { | ||
return this.env.var('CONSUL_ACLS_ENABLED') && !isLegacy([this.item]) && super.canWrite; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.