Skip to content

Commit

Permalink
Backport of Fix OIDC callback query params into release/1.9.x (#15419)
Browse files Browse the repository at this point in the history
* backport of commit 3b3b646

* backport of commit ddbe120

* backport of commit 8d1fe4d

* backport of commit 81f70db

* backport of commit 2c62a16

Co-authored-by: Arnav Palnitkar <arnav@hashicorp.com>
  • Loading branch information
hc-github-team-secure-vault-core and arnav28 committed May 17, 2022
1 parent 91489d5 commit b6c5af7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog/15378.txt
@@ -0,0 +1,3 @@
```release-note:improvement
ui: Allow namespace param to be parsed from state queryParam
```
19 changes: 18 additions & 1 deletion ui/app/routes/vault/cluster/oidc-callback.js
Expand Up @@ -6,11 +6,28 @@ export default Route.extend({
// left blank so we render the template immediately
},
afterModel() {
let { auth_path: path, code, state } = this.paramsFor(this.routeName);
const queryString = decodeURIComponent(window.location.search);
// 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'),
ns;
if (state.includes(',ns=')) {
let arrayParams = state.split(',ns=');
state = arrayParams[0];
ns = arrayParams[1];
}
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
let queryParams = { source, namespace, path, code, state };
// If state had ns value, send it as part of namespace param
if (ns) {
queryParams.namespace = ns;
}
window.opener.postMessage(queryParams, window.origin);
},
renderTemplate() {
Expand Down

0 comments on commit b6c5af7

Please sign in to comment.