vault/ui/app/adapters/role-jwt.js
Angel Garbarino 44af0978e6
Replace all service injects with updated import syntax (#25367)
* replace all injects with import syntax

* Delete ui/app/components/identity/_popup-base.js
2024-02-13 10:00:31 -07:00

39 lines
982 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import ApplicationAdapter from './application';
import { service } from '@ember/service';
import { encodePath } from 'vault/utils/path-encoding-helpers';
export default ApplicationAdapter.extend({
router: service(),
findRecord(store, type, id, snapshot) {
let [path, role] = JSON.parse(id);
path = encodePath(path);
const namespace = snapshot?.adapterOptions.namespace;
const url = `/v1/auth/${path}/oidc/auth_url`;
let redirect_uri = `${window.location.origin}${this.router.urlFor('vault.cluster.oidc-callback', {
auth_path: path,
})}`;
if (namespace) {
redirect_uri = `${window.location.origin}${this.router.urlFor(
'vault.cluster.oidc-callback',
{ auth_path: path },
{ queryParams: { namespace } }
)}`;
}
return this.ajax(url, 'POST', {
data: {
role,
redirect_uri,
},
});
},
});