diff --git a/ui/app/routes/vault/cluster/oidc-callback.js b/ui/app/routes/vault/cluster/oidc-callback.js index c26ac6e553c..6bd992f8dce 100644 --- a/ui/app/routes/vault/cluster/oidc-callback.js +++ b/ui/app/routes/vault/cluster/oidc-callback.js @@ -6,7 +6,18 @@ export default Route.extend({ // left blank so we render the template immediately }, afterModel() { - let { auth_path: path, code, state } = this.paramsFor(this.routeName); + let queryString = window.location.search; + // Check if url is encoded + if (this.containsEncodedComponents(queryString)) { + queryString = decodeURIComponent(queryString); + } + // Since state param can also contain namespace, fetch the values using native url api. + // For instance, state params value can be state=st_123456,ns=d4fq + // Ember paramsFor used to strip out the value after the "=" sign. In short ns value was not being passed along. + let urlParams = new URLSearchParams(queryString); + let state = urlParams.get('state'), + code = urlParams.get('code'); + let { auth_path: path } = this.paramsFor(this.routeName); let { namespaceQueryParam: namespace } = this.paramsFor('vault.cluster'); path = window.decodeURIComponent(path); const source = 'oidc-callback'; // required by event listener in auth-jwt component @@ -17,4 +28,8 @@ export default Route.extend({ this._super(...arguments); controller.set('pageContainer', document.querySelector('.page-container')); }, + // Helper function to check if url is encoded + containsEncodedComponents(x) { + return decodeURI(x) !== decodeURIComponent(x); + }, });