Skip to content

Commit

Permalink
Resolve an issue where we weren't allowing users to login with other …
Browse files Browse the repository at this point in the history
…auth providers

#10974
  • Loading branch information
codyrancher committed May 8, 2024
1 parent 381a15b commit a5e9805
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
11 changes: 5 additions & 6 deletions shell/pages/auth/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,6 @@ export default {
},
created() {
this.providerComponents = this.providers.map((name) => {
return this.$store.getters['type-map/importLogin'](configType[name] || name);
});
},
async fetch() {
const { firstLoginSetting } = await this.loadInitialSettings();
const { value } = await this.$store.dispatch('management/find', { type: MANAGEMENT.SETTING, id: SETTING.BANNERS });
Expand All @@ -135,6 +129,11 @@ export default {
this.customLoginError = JSON.parse(value).loginError;
this.firstLogin = firstLoginSetting?.value === 'true';
this.username = this.firstLogin ? 'admin' : this.username;
this.providerComponents = this.providers.map((name) => {
return this.$store.getters['type-map/importLogin'](configType[name] || name);
});
this.$nextTick(() => {
this.focusSomething();
});
Expand Down
34 changes: 17 additions & 17 deletions shell/pages/auth/verify.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ function isSaml($route) {
}
export default {
async fetch({ store, route, redirect }) {
const code = route.query[GITHUB_CODE];
const stateStr = route.query[GITHUB_NONCE];
async fetch() {
const code = this.$route.query[GITHUB_CODE];
const stateStr = this.$route.query[GITHUB_NONCE];
const {
error, error_description: errorDescription, errorCode, errorMsg
} = route.query;
} = this.$route.query;
if (error || errorDescription || errorCode || errorMsg) {
let out = errorDescription || error || errorCode;
if (errorMsg) {
out = store.getters['i18n/withFallback'](`login.serverError.${ errorMsg }`, null, errorMsg);
out = this.$store.getters['i18n/withFallback'](`login.serverError.${ errorMsg }`, null, errorMsg);
}
redirect(`/auth/login?err=${ escape(out) }`);
this.$router.replace(`/auth/login?err=${ escape(out) }`);
return;
}
Expand All @@ -48,16 +48,16 @@ export default {
try {
parsed = JSON.parse(base64Decode((stateStr)));
} catch (err) {
if (isSaml(route)) {
if (isSaml(this.$route)) {
// This is an ok failure. SAML has no state string so a failure is fine (see similar check in mounted).
// This whole file could be re-written with that in mind, but this change keeps things simple and fixes a breaking addition
return;
}
const out = store.getters['i18n/t'](`login.error`);
const out = this.$store.getters['i18n/t'](`login.error`);
console.error('Failed to parse nonce', stateStr, err); // eslint-disable-line no-console
redirect(`/auth/login?err=${ escape(out) }`);
this.$router.replace(`/auth/login?err=${ escape(out) }`);
return;
}
Expand All @@ -69,28 +69,28 @@ export default {
}
try {
const res = await store.dispatch('auth/verifyOAuth', {
const res = await this.$store.dispatch('auth/verifyOAuth', {
code,
nonce,
provider
});
if ( res._status === 200) {
const backTo = route.query[BACK_TO] || '/';
const backTo = this.$route.query[BACK_TO] || '/';
// Load plugins
await loadPlugins({
app: store.app,
store,
$plugin: store.$plugin
app: this.$store.app,
store: this.$store,
$plugin: this.$store.$plugin
});
redirect(backTo);
this.$router.replace(backTo);
} else {
redirect(`/auth/login?err=${ escape(res) }`);
this.$router.replace(`/auth/login?err=${ escape(res) }`);
}
} catch (err) {
redirect(`/auth/login?err=${ escape(err) }`);
this.$router.replace(`/auth/login?err=${ escape(err) }`);
}
},
Expand Down

0 comments on commit a5e9805

Please sign in to comment.