mirror of
https://github.com/hashicorp/vault.git
synced 2026-02-18 18:38:08 -05:00
Fix OIDC callback query params (#15378)
* Fix OIDC callback query params - Value of namespace was getting stripped from the state query param - Used native URL search param api to fetch the values * Add changelog * Remove unnecessary check for url encoding * Extract ns value and pass as namespace param * Update changelog
This commit is contained in:
parent
a8600a514c
commit
74b1eec537
2 changed files with 21 additions and 1 deletions
3
changelog/15378.txt
Normal file
3
changelog/15378.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
```release-note:improvement
|
||||
ui: Allow namespace param to be parsed from state queryParam
|
||||
```
|
||||
|
|
@ -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);
|
||||
},
|
||||
setupController(controller) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue