diff --git a/edit/auth/ldap/index.vue b/edit/auth/ldap/index.vue
index ae465e70aa..68f2a7ac06 100644
--- a/edit/auth/ldap/index.vue
+++ b/edit/auth/ldap/index.vue
@@ -1,13 +1,12 @@
diff --git a/edit/auth/saml.vue b/edit/auth/saml.vue
index da809ef30c..157d4425e1 100644
--- a/edit/auth/saml.vue
+++ b/edit/auth/saml.vue
@@ -1,6 +1,7 @@
diff --git a/mixins/auth.js b/mixins/auth.js
new file mode 100644
index 0000000000..d25c166e28
--- /dev/null
+++ b/mixins/auth.js
@@ -0,0 +1,116 @@
+import { NORMAN, MANAGEMENT } from '@/config/types';
+import { addObject, findBy } from '@/utils/array';
+
+export default {
+ async fetch() {
+ const NAME = this.$route.params.id;
+ const originalModel = await this.$store.dispatch('rancher/find', {
+ type: NORMAN.AUTH_CONFIG,
+ id: NAME,
+ opt: { url: `/v3/${ NORMAN.AUTH_CONFIG }/${ NAME }`, force: true }
+ });
+
+ const serverUrl = await this.$store.dispatch('management/find', {
+ type: MANAGEMENT.SETTING,
+ id: 'server-url',
+ opt: { url: `/v1/{ MANAGEMENT.SETTING }/server-url` }
+ });
+
+ if ( serverUrl ) {
+ this.serverSetting = serverUrl.value;
+ }
+
+ this.model = await this.$store.dispatch(`rancher/clone`, { resource: originalModel });
+ if (NAME === 'shibboleth' && !this.model.openLdapConfig) {
+ this.model.openLdapConfig = {};
+ this.showLdap = false;
+ }
+ },
+
+ computed: {
+ me() {
+ const out = findBy(this.principals, 'me', true);
+
+ return out;
+ },
+
+ serverUrl() {
+ if ( this.serverSetting ) {
+ return this.serverSetting;
+ } else if ( process.client ) {
+ return window.location.origin;
+ }
+
+ return '';
+ },
+
+ principal() {
+ return this.$store.getters['rancher/byId'](NORMAN.PRINCIPAL, this.$store.getters['auth/principalId']) || {};
+ },
+
+ displayName() {
+ return this.t(`model.authConfig.provider.${ this.NAME }`);
+ },
+
+ NAME() {
+ return this.$route.params.id;
+ },
+
+ AUTH_CONFIG() {
+ return MANAGEMENT.AUTH_CONFIG;
+ }
+ },
+
+ methods: {
+ async save(btnCb) {
+ this.errors = [];
+ const wasEnabled = this.model.enabled;
+ let obj = this.toSave;
+
+ if (!obj) {
+ obj = this.model;
+ }
+
+ try {
+ if ( !wasEnabled ) {
+ this.model.enabled = true;
+
+ if (this.model.id === 'googleoauth' || this.model.id === 'github') {
+ const code = await this.$store.dispatch('auth/test', { provider: this.model.id, body: this.model });
+
+ this.model.enabled = true;
+ obj.code = code;
+ }
+
+ await this.model.doAction('testAndApply', obj);
+
+ // Reload principals to get the new ones from the provider
+ this.principals = await this.$store.dispatch('rancher/findAll', {
+ type: NORMAN.PRINCIPAL,
+ opt: { url: '/v3/principals', force: true }
+ });
+
+ this.model.allowedPrincipalIds = this.model.allowedPrincipalIds || [];
+ if ( this.me && !this.model.allowedPrincipalIds.includes(this.me.id) ) {
+ addObject(this.model.allowedPrincipalIds, this.me.id);
+ }
+ }
+
+ if (this.model.configType === 'oauth') {
+ await this.model.save();
+ await this.reloadModel();
+ }
+
+ btnCb(true);
+ if ( wasEnabled ) {
+ this.done();
+ }
+ this.$router.applyQuery( { mode: 'view' } );
+ } catch (err) {
+ this.errors = [err];
+ btnCb(false);
+ this.model.enabled = wasEnabled;
+ }
+ },
+ },
+};
diff --git a/models/management.cattle.io.authconfig.js b/models/management.cattle.io.authconfig.js
index bc28e13bc3..e449772d72 100644
--- a/models/management.cattle.io.authconfig.js
+++ b/models/management.cattle.io.authconfig.js
@@ -1,4 +1,5 @@
import { insertAt } from '@/utils/array';
+import { set } from '@/utils/object';
const configType = {
activedirectory: 'ldap',
@@ -61,5 +62,26 @@ export default {
await this.save();
this.currentRouter().push({ name: 'c-cluster-auth-config' });
};
+ },
+
+ applyDefaults() {
+ return () => {
+ switch (this.configType) {
+ case 'saml':
+ if (this.id === 'shibboleth' && !this.openLdapConfig) {
+ this.openLdapConfig = {};
+ set(this, 'openLdapConfig', {});
+ }
+ break;
+ case 'ldap':
+ set(this, 'servers', []);
+ set(this, 'accessMode', 'unrestricted');
+ set(this, 'starttls', false);
+
+ break;
+ default:
+ break;
+ }
+ };
}
};
diff --git a/store/auth.js b/store/auth.js
index 07a356bb89..7f9d7f6b0b 100644
--- a/store/auth.js
+++ b/store/auth.js
@@ -5,7 +5,8 @@ import { open, popupWindowOptions } from '@/utils/window';
import {
BACK_TO, SPA, AUTH_TEST, _FLAGGED, GITHUB_SCOPE, GITHUB_NONCE, GITHUB_REDIRECT
} from '@/config/query-params';
-import { BASE_SCOPES } from '@/store/github';
+
+export const BASE_SCOPES = { github: ['read:org'], googleoauth: ['email'] };
const KEY = 'rc_nonce';
@@ -143,7 +144,7 @@ export const actions = {
const fromQuery = unescape(parseUrl(redirectUrl).query?.[GITHUB_SCOPE] || '');
const scopes = fromQuery.split(/[, ]+/).filter(x => !!x);
- addObjects(scopes, BASE_SCOPES);
+ addObjects(scopes, BASE_SCOPES[provider]);
if ( opt.scopes ) {
addObjects(scopes, opt.scopes);
diff --git a/store/github.js b/store/github.js
index fafb3e9520..b0f0a4a889 100644
--- a/store/github.js
+++ b/store/github.js
@@ -5,7 +5,6 @@ import { GITHUB_REPOS, GITHUB_SCOPES, _DATE } from '@/config/local-storage';
const API_BASE = 'https://api.github.com/';
-export const BASE_SCOPES = ['read:org'];
export const EXTENDED_SCOPES = ['repo'];
export const DOCKERFILE = /^Dockerfile(\..*)?$/i;
From 09f6228d5ca23eabb03eb0ae56828c616d9bff59 Mon Sep 17 00:00:00 2001
From: Nancy Butler <42977925+mantis-toboggan-md@users.noreply.github.com>
Date: Tue, 12 Jan 2021 09:45:21 -0700
Subject: [PATCH 03/18] fix saml enable and ldap disable
---
assets/translations/en-us.yaml | 1 +
edit/auth/github.vue | 28 +---------
edit/auth/googleoauth.vue | 2 +-
edit/auth/ldap/config.vue | 17 +++---
edit/auth/ldap/index.vue | 14 +++--
edit/auth/saml.vue | 13 ++++-
mixins/auth.js | 65 ++++++++++++++++++++---
models/management.cattle.io.authconfig.js | 3 +-
8 files changed, 93 insertions(+), 50 deletions(-)
diff --git a/assets/translations/en-us.yaml b/assets/translations/en-us.yaml
index 9116b3609b..3b98fb3dcd 100644
--- a/assets/translations/en-us.yaml
+++ b/assets/translations/en-us.yaml
@@ -184,6 +184,7 @@ authConfig:
freeipa: Configure a FreeIPA server
activedirectory: Configure an Active Directory account
openldap: Configure an OpenLDAP server
+ defaultLoginDomain: Default Login Domain
cert: Certificate
disabledStatusBitmask: Disabled Status Bitmask
groupDNAttribute: Group DN Attribute
diff --git a/edit/auth/github.vue b/edit/auth/github.vue
index 60f18aa089..73ab05c201 100644
--- a/edit/auth/github.vue
+++ b/edit/auth/github.vue
@@ -121,18 +121,6 @@ export default {
},
methods: {
- async reloadModel() {
- this.originalModel = await this.$store.dispatch('rancher/find', {
- type: NORMAN.AUTH_CONFIG,
- id: NAME,
- opt: { url: `/v3/${ NORMAN.AUTH_CONFIG }/${ NAME }`, force: true }
- });
-
- this.model = await this.$store.dispatch(`rancher/clone`, { resource: this.originalModel });
-
- return this.model;
- },
-
updateHost() {
const match = this.targetUrl.match(/^(((https?):)?\/\/)?([^/]+)(\/.*)?$/);
@@ -146,20 +134,6 @@ export default {
this.model.hostname = match[4] || 'github.com';
}
},
-
- async disable(btnCb) {
- try {
- const clone = await this.$store.dispatch(`rancher/clone`, { resource: this.model });
-
- clone.enabled = false;
- await clone.save();
- await this.reloadModel();
- btnCb(true);
- } catch (err) {
- this.errors = [err];
- btnCb(false);
- }
- }
},
};
@@ -180,7 +154,7 @@ export default {
@finish="save"
@cancel="done"
>
-
+
{{ t('authConfig.stateBanner.enabled', tArgs) }}
diff --git a/edit/auth/googleoauth.vue b/edit/auth/googleoauth.vue
index c20549f100..7cf53b6aee 100644
--- a/edit/auth/googleoauth.vue
+++ b/edit/auth/googleoauth.vue
@@ -113,7 +113,7 @@ export default {
@finish="save"
@cancel="done"
>
-
+
{{ t('authConfig.stateBanner.enabled', tArgs) }}
diff --git a/edit/auth/ldap/config.vue b/edit/auth/ldap/config.vue
index c1c0f3b70f..c0bbbd12e5 100644
--- a/edit/auth/ldap/config.vue
+++ b/edit/auth/ldap/config.vue
@@ -80,21 +80,22 @@ export default {
-
-
-
-
-
-
+
-
diff --git a/edit/auth/ldap/index.vue b/edit/auth/ldap/index.vue
index 68f2a7ac06..fb60579b4d 100644
--- a/edit/auth/ldap/index.vue
+++ b/edit/auth/ldap/index.vue
@@ -6,6 +6,7 @@ import CruResource from '@/components/CruResource';
import LabeledInput from '@/components/form/LabeledInput';
import Banner from '@/components/Banner';
import AllowedPrincipals from '@/components/auth/AllowedPrincipals';
+import AsyncButton from '@/components/AsyncButton';
import config from '@/edit/auth/ldap/config';
const AUTH_TYPE = 'ldap';
@@ -17,6 +18,7 @@ export default {
LabeledInput,
Banner,
AllowedPrincipals,
+ AsyncButton,
config
},
@@ -84,9 +86,15 @@ export default {
@finish="save"
@cancel="done"
>
-
-
-
+
+
+
+ {{ t('authConfig.stateBanner.enabled', tArgs) }}
+
+
+
Server: {{ serverUrl }}
Client ID: {{ model.serviceAccountDistinguishedName || model.serviceAccountUsername }}
diff --git a/edit/auth/saml.vue b/edit/auth/saml.vue
index 157d4425e1..3577e9d12a 100644
--- a/edit/auth/saml.vue
+++ b/edit/auth/saml.vue
@@ -7,6 +7,7 @@ import LabeledInput from '@/components/form/LabeledInput';
import Checkbox from '@/components/form/Checkbox';
import Banner from '@/components/Banner';
import AllowedPrincipals from '@/components/auth/AllowedPrincipals';
+import AsyncButton from '@/components/AsyncButton';
import FileSelector from '@/components/form/FileSelector';
import config from '@/edit/auth/ldap/config';
@@ -21,6 +22,7 @@ export default {
AllowedPrincipals,
Checkbox,
FileSelector,
+ AsyncButton,
config
},
@@ -74,8 +76,15 @@ export default {
@finish="save"
@cancel="done"
>
-
-
+
+
+
+ {{ t('authConfig.stateBanner.enabled', tArgs) }}
+
+
+
Server: {{ baseUrl }}
Display Name: {{ model.displayNameField }}
diff --git a/mixins/auth.js b/mixins/auth.js
index d25c166e28..0dd6eaaa5e 100644
--- a/mixins/auth.js
+++ b/mixins/auth.js
@@ -27,6 +27,10 @@ export default {
}
},
+ data() {
+ return { isSaving: false };
+ },
+
computed: {
me() {
const out = findBy(this.principals, 'me', true);
@@ -63,6 +67,9 @@ export default {
methods: {
async save(btnCb) {
+ const configType = this.value.configType;
+
+ this.isSaving = true;
this.errors = [];
const wasEnabled = this.model.enabled;
let obj = this.toSave;
@@ -73,16 +80,26 @@ export default {
try {
if ( !wasEnabled ) {
- this.model.enabled = true;
-
- if (this.model.id === 'googleoauth' || this.model.id === 'github') {
+ if (configType === 'oauth') {
const code = await this.$store.dispatch('auth/test', { provider: this.model.id, body: this.model });
this.model.enabled = true;
obj.code = code;
}
-
- await this.model.doAction('testAndApply', obj);
+ if (configType === 'saml') {
+ this.model.enabled = true;
+ if (!this.model.accessMode) {
+ this.model.accessMode = 'unrestricted';
+ }
+ await this.model.save();
+ await this.model.doAction('testAndEnable', obj);
+ } else {
+ this.model.enabled = true;
+ if (!this.model.accessMode) {
+ this.model.accessMode = 'unrestricted';
+ }
+ await this.model.doAction('testAndApply', obj);
+ }
// Reload principals to get the new ones from the provider
this.principals = await this.$store.dispatch('rancher/findAll', {
@@ -96,21 +113,53 @@ export default {
}
}
- if (this.model.configType === 'oauth') {
+ if (configType === 'oauth') {
await this.model.save();
await this.reloadModel();
}
-
+ this.isSaving = false;
btnCb(true);
if ( wasEnabled ) {
this.done();
}
- this.$router.applyQuery( { mode: 'view' } );
+ // this.$router.applyQuery( { mode: 'view' } );
} catch (err) {
this.errors = [err];
btnCb(false);
this.model.enabled = wasEnabled;
+ this.isSaving = false;
}
},
+
+ async disable(btnCb) {
+ try {
+ if (this.model.hasAction('disable')) {
+ await this.model.doAction('disable');
+ } else {
+ const clone = await this.$store.dispatch(`rancher/clone`, { resource: this.model });
+
+ clone.enabled = false;
+ await clone.save();
+ }
+ await this.reloadModel();
+
+ btnCb(true);
+ } catch (err) {
+ this.errors = [err];
+ btnCb(false);
+ }
+ },
+
+ async reloadModel() {
+ this.originalModel = await this.$store.dispatch('rancher/find', {
+ type: NORMAN.AUTH_CONFIG,
+ id: this.NAME,
+ opt: { url: `/v3/${ NORMAN.AUTH_CONFIG }/${ this.NAME }`, force: true }
+ });
+
+ this.model = await this.$store.dispatch(`rancher/clone`, { resource: this.originalModel });
+
+ return this.model;
+ },
},
};
diff --git a/models/management.cattle.io.authconfig.js b/models/management.cattle.io.authconfig.js
index e449772d72..cfcc4efb2a 100644
--- a/models/management.cattle.io.authconfig.js
+++ b/models/management.cattle.io.authconfig.js
@@ -68,8 +68,9 @@ export default {
return () => {
switch (this.configType) {
case 'saml':
+ set(this, 'accessMode', 'unrestricted');
+
if (this.id === 'shibboleth' && !this.openLdapConfig) {
- this.openLdapConfig = {};
set(this, 'openLdapConfig', {});
}
break;
From 7287c22cfde3c5301ed6a1e95552af7334b811cd Mon Sep 17 00:00:00 2001
From: Westly Wright
Date: Mon, 11 Jan 2021 13:32:28 -0700
Subject: [PATCH 04/18] Add requireed to external name
rancher/dashboard#2179
---
edit/service.vue | 1 +
1 file changed, 1 insertion(+)
diff --git a/edit/service.vue b/edit/service.vue
index b202f5707a..70312c8556 100644
--- a/edit/service.vue
+++ b/edit/service.vue
@@ -226,6 +226,7 @@ export default {
:mode="mode"
:label="t('servicesPage.externalName.input.label')"
:placeholder="t('servicesPage.externalName.placeholder')"
+ :required="true"
type="text"
/>
From d4cf09dd90d6f95a7ebc757f06c035b4a2863312 Mon Sep 17 00:00:00 2001
From: Westly Wright
Date: Mon, 11 Jan 2021 15:47:28 -0700
Subject: [PATCH 05/18] Updates service selector to match target pods realtime
rancher/dashboard#717
---
assets/translations/en-us.yaml | 9 ++-
edit/service.vue | 137 ++++++++++++++++++++++++++-------
2 files changed, 118 insertions(+), 28 deletions(-)
diff --git a/assets/translations/en-us.yaml b/assets/translations/en-us.yaml
index 96a4e392de..62ae4a75f6 100644
--- a/assets/translations/en-us.yaml
+++ b/assets/translations/en-us.yaml
@@ -1606,8 +1606,15 @@ servicesPage:
ports:
label: Ports
selectors:
- helpText: "If no selector is created, manual endpoints must be made."
+ helpText: ""
label: Selectors
+ matchingPods:
+ matchesSome: |-
+ {matched, plural,
+ =0 {Matches 0 of {total, number} pods. If no selector is created, manual endpoints must be made.}
+ =1 {Matches 1 of {total, number} pods: "{sample}"}
+ other {Matches {matched, number} of {total, number} existing pods, including "{sample}"}
+ }
serviceTypes:
clusterIp:
abbrv: IP
diff --git a/edit/service.vue b/edit/service.vue
index 70312c8556..e3cbc8313a 100644
--- a/edit/service.vue
+++ b/edit/service.vue
@@ -1,5 +1,6 @@
@@ -201,10 +262,10 @@ export default {
:subtypes="defaultServiceTypes"
:validation-passed="true"
:errors="errors"
- @error="e=>errors = e"
+ @error="(e) => (errors = e)"
@finish="save"
@cancel="done"
- @select-type="(st) => serviceType = st"
+ @select-type="(st) => (serviceType = st)"
@apply-hooks="() => applyHooks('_beforeSaveHooks')"
>
@@ -232,7 +293,12 @@ export default {
-
+
@@ -259,24 +327,27 @@ export default {
:mode="mode"
:initial-empty-row="true"
:protip="false"
- @input="e=>$set(value.spec, 'selector', e)"
+ @input="(e) => $set(value.spec, 'selector', e)"
/>