diff --git a/ui/packages/consul-ui/app/components/consul/auth-method/index.scss b/ui/packages/consul-ui/app/components/consul/auth-method/index.scss index de2f4eb28b..f0f1130f0b 100644 --- a/ui/packages/consul-ui/app/components/consul/auth-method/index.scss +++ b/ui/packages/consul-ui/app/components/consul/auth-method/index.scss @@ -24,9 +24,17 @@ font-weight: $typo-weight-semibold; font-size: $typo-size-700; } - tbody td { - font-size: $typo-size-600; - color: $black; + tbody { + td { + font-size: $typo-size-600; + color: $black; + } + tr { + cursor: default; + } + tr:hover { + box-shadow: none; + } } } } @@ -54,4 +62,26 @@ } } +// Nspace List +.consul-auth-method-nspace-list { + thead { + td { + color: var(--gray-500) !important; + font-weight: $typo-weight-semibold !important; + font-size: $typo-size-700 !important; + } + } + tbody { + td { + font-size: $typo-size-600; + color: $black; + } + tr { + cursor: default; + } + tr:hover { + box-shadow: none; + } + } +} diff --git a/ui/packages/consul-ui/app/components/consul/auth-method/nspace-list/index.hbs b/ui/packages/consul-ui/app/components/consul/auth-method/nspace-list/index.hbs new file mode 100644 index 0000000000..841db0093b --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/auth-method/nspace-list/index.hbs @@ -0,0 +1,19 @@ +
+ + + + + + + + + {{#each @items as |item|}} + + + + + {{/each}} + +
{{t "models.auth-method.Selector"}}{{t "models.auth-method.BindNamespace"}}
{{item.Selector}}{{item.BindNamespace}}
+
+ diff --git a/ui/packages/consul-ui/app/models/auth-method.js b/ui/packages/consul-ui/app/models/auth-method.js index a2aaf6c792..38da49b629 100644 --- a/ui/packages/consul-ui/app/models/auth-method.js +++ b/ui/packages/consul-ui/app/models/auth-method.js @@ -14,6 +14,7 @@ export default class AuthMethod extends Model { @attr('string', { defaultValue: () => '' }) DisplayName; @attr('string', { defaultValue: () => 'local' }) TokenLocality; @attr('string') Type; + @attr() NamespaceRules; @or('DisplayName', 'Name') MethodName; @attr() Config; @attr('string') MaxTokenTTL; diff --git a/ui/packages/consul-ui/app/router.js b/ui/packages/consul-ui/app/router.js index 14cb6656f5..f17c65d200 100644 --- a/ui/packages/consul-ui/app/router.js +++ b/ui/packages/consul-ui/app/router.js @@ -199,6 +199,9 @@ export const routes = { 'binding-rules': { _options: { path: '/binding-rules' }, }, + 'nspace-rules': { + _options: { path: '/nspace-rules' }, + }, }, }, }, diff --git a/ui/packages/consul-ui/app/routes/dc/acls/auth-methods/show/nspace-rules.js b/ui/packages/consul-ui/app/routes/dc/acls/auth-methods/show/nspace-rules.js new file mode 100644 index 0000000000..8ea762d012 --- /dev/null +++ b/ui/packages/consul-ui/app/routes/dc/acls/auth-methods/show/nspace-rules.js @@ -0,0 +1,16 @@ +import Route from 'consul-ui/routing/route'; + +export default class NspaceRulesRoute extends Route { + model() { + const parent = this.routeName + .split('.') + .slice(0, -1) + .join('.'); + return this.modelFor(parent); + } + + setupController(controller, model) { + super.setupController(...arguments); + controller.setProperties(model); + } +} diff --git a/ui/packages/consul-ui/app/templates/dc/acls/auth-methods/show.hbs b/ui/packages/consul-ui/app/templates/dc/acls/auth-methods/show.hbs index 52e86479cf..489d36409a 100644 --- a/ui/packages/consul-ui/app/templates/dc/acls/auth-methods/show.hbs +++ b/ui/packages/consul-ui/app/templates/dc/acls/auth-methods/show.hbs @@ -27,6 +27,9 @@ compact (array (hash label="General info" href=(href-to "dc.acls.auth-methods.show.auth-method") selected=(is-href "dc.acls.auth-methods.show.auth-method")) + (if (env "CONSUL_NSPACES_ENABLED") + (hash label="Namespace rules" href=(href-to "dc.acls.auth-methods.show.nspace-rules") selected=(is-href "dc.acls.auth-methods.show.nspace-rules")) + '') (hash label="Binding rules" href=(href-to "dc.acls.auth-methods.show.binding-rules") selected=(is-href "dc.acls.auth-methods.show.binding-rules")) ) }}/> diff --git a/ui/packages/consul-ui/app/templates/dc/acls/auth-methods/show/nspace-rules.hbs b/ui/packages/consul-ui/app/templates/dc/acls/auth-methods/show/nspace-rules.hbs new file mode 100644 index 0000000000..9a58a6527f --- /dev/null +++ b/ui/packages/consul-ui/app/templates/dc/acls/auth-methods/show/nspace-rules.hbs @@ -0,0 +1,21 @@ + +
+{{#if true}} +

A set of rules that can control which namespace tokens created via this auth method will be created within. Unlike binding rules, the first matching namespace rule wins.

+ +{{else}} + + +

No namespace rules

+
+ +

A set of rules that can control which namespace tokens created via this auth method will be created within. Unlike binding rules, the first matching namespace rule wins.

+
+ + + +
+{{/if}} +
diff --git a/ui/packages/consul-ui/mock-api/v1/acl/auth-method/_ b/ui/packages/consul-ui/mock-api/v1/acl/auth-method/_ index fb231512a3..c2313674a2 100644 --- a/ui/packages/consul-ui/mock-api/v1/acl/auth-method/_ +++ b/ui/packages/consul-ui/mock-api/v1/acl/auth-method/_ @@ -28,6 +28,20 @@ SmTjcs+lhMxg4fFY6lBpiEVFiGUjGRR+61R67Lz6U4KJeLNcCm07QwFYKBmpi08g const listClaimMappings = { "http://example.com/example-1": `${fake.hacker.noun()}` } + const namespaceRules = `[ + { + "Selector": "${fake.hacker.noun()} in list.group", + "BindNamespace": "dc-1" + }, + { + "Selector": "serviceaccount.namespace!=${fake.hacker.noun()}", + "BindNamespace": "dc-2" + }, + { + "Selector": "serviceaccount.namespace==${fake.hacker.noun()}", + "BindNamespace": "dc-3" + } + ]`; let config = {}; switch(type) { @@ -91,6 +105,7 @@ SmTjcs+lhMxg4fFY6lBpiEVFiGUjGRR+61R67Lz6U4KJeLNcCm07QwFYKBmpi08g "DisplayName": "${fake.hacker.noun()}", "MaxTokenTTL": "${fake.random.number({min: 0, max: 60})}m${fake.random.number({min: 0, max: 60})}s", "TokenLocality": "${fake.helpers.randomize(['local', 'global', ''])}", + "NamespaceRules": ${namespaceRules}, "Config": ${JSON.stringify(config)}, "CreateIndex": ${fake.random.number()}, "ModifyIndex": 10 diff --git a/ui/packages/consul-ui/translations/en-us.yaml b/ui/packages/consul-ui/translations/en-us.yaml index 85a44a0b16..9aa5afc751 100644 --- a/ui/packages/consul-ui/translations/en-us.yaml +++ b/ui/packages/consul-ui/translations/en-us.yaml @@ -192,6 +192,8 @@ models: TokenLocality: Token locality Type: Type MaxTokenTTL: Maximum token TTL + Selector: Selector + BindNamespace: Bind Namespace Config: Host: Host CACert: CA Cert