2023-03-14 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-14 13:18:55 +00:00
|
|
|
*/
|
|
|
|
|
2021-11-18 15:52:39 +00:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import { action } from '@ember/object';
|
|
|
|
import { tracked } from '@glimmer/tracking';
|
2020-05-11 15:37:11 +00:00
|
|
|
|
|
|
|
import chart from './chart.xstate';
|
2021-11-18 15:52:39 +00:00
|
|
|
|
|
|
|
export default class TokenSource extends Component {
|
|
|
|
@tracked provider;
|
|
|
|
@tracked jwt;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super(...arguments);
|
2020-05-11 15:37:11 +00:00
|
|
|
this.chart = chart;
|
2021-11-18 15:52:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
isSecret() {
|
|
|
|
return this.args.type === 'secret';
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
change(e) {
|
2022-09-15 08:43:17 +00:00
|
|
|
e.data.toJSON = function () {
|
2021-11-18 15:52:39 +00:00
|
|
|
return {
|
|
|
|
AccessorID: this.AccessorID,
|
|
|
|
// TODO: In the past we've always ignored the SecretID returned
|
|
|
|
// from the server and used what the user typed in instead, now
|
|
|
|
// as we don't know the SecretID when we use SSO we use the SecretID
|
|
|
|
// in the response
|
|
|
|
SecretID: this.SecretID,
|
|
|
|
Namespace: this.Namespace,
|
|
|
|
Partition: this.Partition,
|
|
|
|
...{
|
|
|
|
AuthMethod: typeof this.AuthMethod !== 'undefined' ? this.AuthMethod : undefined,
|
|
|
|
// TODO: We should be able to only set namespaces if they are enabled
|
|
|
|
// but we might be testing for nspaces everywhere
|
|
|
|
// Namespace: typeof this.Namespace !== 'undefined' ? this.Namespace : undefined
|
|
|
|
},
|
2020-05-11 15:37:11 +00:00
|
|
|
};
|
2021-11-18 15:52:39 +00:00
|
|
|
};
|
|
|
|
// TODO: We should probably put the component into idle state
|
2022-09-15 08:43:17 +00:00
|
|
|
if (typeof this.args.onchange === 'function') {
|
2021-11-18 15:52:39 +00:00
|
|
|
this.args.onchange(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|