diff --git a/changelog/17661.txt b/changelog/17661.txt
new file mode 100644
index 000000000..5dfb8ea76
--- /dev/null
+++ b/changelog/17661.txt
@@ -0,0 +1,3 @@
+```release-note:bug
+ui: Fixes oidc/jwt login issue with alternate mount path and jwt login via mount path tab
+```
\ No newline at end of file
diff --git a/ui/app/components/auth-form.js b/ui/app/components/auth-form.js
index 9b753b2bd..c5ebc4c7b 100644
--- a/ui/app/components/auth-form.js
+++ b/ui/app/components/auth-form.js
@@ -2,7 +2,6 @@ import Ember from 'ember';
import { next } from '@ember/runloop';
import { inject as service } from '@ember/service';
import { match, alias, or } from '@ember/object/computed';
-import { assign } from '@ember/polyfills';
import { dasherize } from '@ember/string';
import Component from '@ember/component';
import { computed } from '@ember/object';
@@ -284,25 +283,24 @@ export default Component.extend(DEFAULTS, {
}),
actions: {
- doSubmit(passedData, event) {
+ doSubmit(passedData, event, token) {
if (event) {
event.preventDefault();
}
- let data = {};
- this.setProperties({
- error: null,
- });
- // if callback from oidc we have a token at this point
- let backend =
- this.providerName === 'oidc' ? this.getAuthBackend('token') : this.selectedAuthBackend || {};
- let backendMeta = BACKENDS.find(
+ if (token) {
+ this.set('token', token);
+ }
+ this.set('error', null);
+ // if callback from oidc or jwt we have a token at this point
+ const backend = token ? this.getAuthBackend('token') : this.selectedAuthBackend || {};
+ const backendMeta = BACKENDS.find(
(b) => (b.type || '').toLowerCase() === (backend.type || '').toLowerCase()
);
- let attributes = (backendMeta || {}).formAttributes || [];
+ const attributes = (backendMeta || {}).formAttributes || [];
+ const data = this.getProperties(...attributes);
- data = assign(data, this.getProperties(...attributes));
if (passedData) {
- data = assign(data, passedData);
+ Object.assign(data, passedData);
}
if (this.customPath || backend.id) {
data.path = this.customPath || backend.id;
diff --git a/ui/app/components/auth-jwt.js b/ui/app/components/auth-jwt.js
index 1605aadea..9e6e5ae13 100644
--- a/ui/app/components/auth-jwt.js
+++ b/ui/app/components/auth-jwt.js
@@ -18,6 +18,7 @@ export { ERROR_WINDOW_CLOSED, ERROR_MISSING_PARAMS, ERROR_JWT_LOGIN };
export default Component.extend({
store: service(),
featureFlagService: service('featureFlag'),
+
selectedAuthPath: null,
selectedAuthType: null,
roleName: null,
@@ -26,22 +27,18 @@ export default Component.extend({
onRoleName() {},
onLoading() {},
onError() {},
- onToken() {},
onNamespace() {},
didReceiveAttrs() {
this._super();
- let { oldSelectedAuthPath, selectedAuthPath } = this;
- let shouldDebounce = !oldSelectedAuthPath && !selectedAuthPath;
- if (oldSelectedAuthPath !== selectedAuthPath) {
- this.set('role', null);
- this.onRoleName(this.roleName);
- this.fetchRole.perform(null, { debounce: false });
- } else if (shouldDebounce) {
- this.fetchRole.perform(this.roleName);
+ const debounce = !this.oldSelectedAuthPath && !this.selectedAuthPath;
+
+ if (this.oldSelectedAuthPath !== this.selectedAuthPath || debounce) {
+ this.fetchRole.perform(this.roleName, { debounce });
}
+
this.set('errorMessage', null);
- this.set('oldSelectedAuthPath', selectedAuthPath);
+ this.set('oldSelectedAuthPath', this.selectedAuthPath);
},
// Assumes authentication using OIDC until it's known that the mount is
@@ -165,9 +162,7 @@ export default Component.extend({
} catch (e) {
return this.handleOIDCError(e);
}
- let token = resp.auth.client_token;
- this.onToken(token);
- yield this.onSubmit();
+ yield this.onSubmit(null, null, resp.auth.client_token);
}),
actions: {
@@ -177,6 +172,14 @@ export default Component.extend({
e.preventDefault();
}
if (!this.isOIDC || !this.role || !this.role.authUrl) {
+ let message = this.errorMessage;
+ if (!this.role) {
+ message = 'Invalid role. Please try again.';
+ } else if (!this.role.authUrl) {
+ message =
+ 'Missing auth_url. Please check that allowed_redirect_uris for the role include this mount path.';
+ }
+ this.onError(message);
return;
}
try {
diff --git a/ui/app/components/okta-number-challenge.js b/ui/app/components/okta-number-challenge.js
deleted file mode 100644
index 7c9566e11..000000000
--- a/ui/app/components/okta-number-challenge.js
+++ /dev/null
@@ -1,24 +0,0 @@
-import Component from '@glimmer/component';
-
-/**
- * @module OktaNumberChallenge
- * OktaNumberChallenge components are used to display loading screen and correct answer for Okta Number Challenge when signing in through Okta
- *
- * @example
- * ```js
- *
To finish signing in, you will need to complete an additional MFA step.
- {{#if this.errorThrown}} + {{#if @hasError}}Okta verification
@@ -21,7 +21,7 @@