Icu 5578 - introduce injected application credential on the api (#1269)
* chore: 🤖 include injected cred sources to the target model
This commit is contained in:
1 parent
bd0854b0f6
commit
2614b311a1
11 files changed
+395
-171
No files matched your search
@@ -20,7 +20,7 @@ export default class TargetModel extends GeneratedTargetModel {
|
||||
host_sources;
|
||||
|
||||
/**
|
||||
* Credential source ids are read only and can be
|
||||
* Brokered Credential source ids are read only and can be
|
||||
* persisted via a dedicated call to `addBrokeredCredentialSources()`.
|
||||
*/
|
||||
@attr('string-array', {
|
||||
@@ -29,6 +29,16 @@ export default class TargetModel extends GeneratedTargetModel {
|
||||
})
|
||||
brokered_credential_source_ids;
|
||||
|
||||
/**
|
||||
* Injected Application Credential source ids are read only and can be
|
||||
* persisted via a dedicated call to `addInjectedApplicationCredentialSources()`.
|
||||
*/
|
||||
@attr('string-array', {
|
||||
readOnly: true,
|
||||
emptyArrayIfMissing: true,
|
||||
})
|
||||
injected_application_credential_source_ids;
|
||||
|
||||
/**
|
||||
* An array of resolved host set and host catalog instances. Model instances
|
||||
* must already be loaded into the store (this method will not load unloaded
|
||||
@@ -62,6 +72,24 @@ export default class TargetModel extends GeneratedTargetModel {
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of resolved credential library and credential instances. Model instances
|
||||
* must already be loaded into the store (this method will not load unloaded
|
||||
* instances). Unresolvable instances are excluded from the array.
|
||||
* @type {[CredentialLibraryModel, CredentialModel]}
|
||||
*/
|
||||
get injectedApplicationCredentialSources() {
|
||||
return this.injected_application_credential_source_ids
|
||||
.map((source) => {
|
||||
if (source.value.startsWith('cred')) {
|
||||
return this.store.peekRecord('credential', source.value);
|
||||
} else {
|
||||
return this.store.peekRecord('credential-library', source.value);
|
||||
}
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sessions associated with this target (but only already loaded sessions).
|
||||
* @type {SessionModel[]}
|
||||
@@ -152,18 +180,44 @@ export default class TargetModel extends GeneratedTargetModel {
|
||||
/**
|
||||
* Adds credential sources via the `add-credential-sources` method.
|
||||
* See serializer and adapter for more information.
|
||||
* @param {[string]} credentialSourceIDs
|
||||
* @param {[string]} brokeredCredentialSourceIDs
|
||||
* @param {object} options
|
||||
* @param {object} options.adapterOptions
|
||||
* @return {Promise}
|
||||
*/
|
||||
addBrokeredCredentialSources(
|
||||
credentialSourceIDs,
|
||||
brokeredCredentialSourceIDs,
|
||||
options = { adapterOptions: {} }
|
||||
) {
|
||||
const defaultAdapterOptions = {
|
||||
method: 'add-credential-sources',
|
||||
credentialSourceIDs,
|
||||
brokeredCredentialSourceIDs,
|
||||
};
|
||||
// There is no "deep merge" in ES.
|
||||
return this.save({
|
||||
...options,
|
||||
adapterOptions: {
|
||||
...defaultAdapterOptions,
|
||||
...options.adapterOptions,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds credential sources via the `add-credential-sources` method.
|
||||
* See serializer and adapter for more information.
|
||||
* @param {[string]} injectedApplicationCredentialSourceIDs
|
||||
* @param {object} options
|
||||
* @param {object} options.adapterOptions
|
||||
* @return {Promise}
|
||||
*/
|
||||
addInjectedApplicationCredentialSources(
|
||||
injectedApplicationCredentialSourceIDs,
|
||||
options = { adapterOptions: {} }
|
||||
) {
|
||||
const defaultAdapterOptions = {
|
||||
method: 'add-credential-sources',
|
||||
injectedApplicationCredentialSourceIDs,
|
||||
};
|
||||
// There is no "deep merge" in ES.
|
||||
return this.save({
|
||||
@@ -178,18 +232,18 @@ export default class TargetModel extends GeneratedTargetModel {
|
||||
/**
|
||||
* Delete credential libraries and credentials via the `remove-credential-sources` method.
|
||||
* See serializer and adapter for more information.
|
||||
* @param {[string]} credentialSourceIDs
|
||||
* @param {[string]} brokeredCredentialSourceIDs
|
||||
* @param {object} options
|
||||
* @param {object} options.adapterOptions
|
||||
* @return {Promise}
|
||||
*/
|
||||
removeBrokeredCredentialSources(
|
||||
credentialSourceIDs,
|
||||
brokeredCredentialSourceIDs,
|
||||
options = { adapterOptions: {} }
|
||||
) {
|
||||
const defaultAdapterOptions = {
|
||||
method: 'remove-credential-sources',
|
||||
credentialSourceIDs,
|
||||
brokeredCredentialSourceIDs,
|
||||
};
|
||||
// There is no "deep merge" in ES.
|
||||
return this.save({
|
||||
@@ -203,14 +257,58 @@ export default class TargetModel extends GeneratedTargetModel {
|
||||
|
||||
/**
|
||||
* Delete a single credential library/credential set via the `remove-credential-sources` method.
|
||||
* @param {number} credentialSourceID
|
||||
* @param {number} brokeredCredentialSourceID
|
||||
* @param {object} options
|
||||
* @return {Promise}
|
||||
*/
|
||||
removeBrokeredCredentialSource(credentialSourceID, options) {
|
||||
return this.removeBrokeredCredentialSources([credentialSourceID], options);
|
||||
removeBrokeredCredentialSource(brokeredCredentialSourceID, options) {
|
||||
return this.removeBrokeredCredentialSources(
|
||||
[brokeredCredentialSourceID],
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete credential libraries and credentials via the `remove-credential-sources` method.
|
||||
* See serializer and adapter for more information.
|
||||
* @param {[string]} injectedApplicationCredentialSourceIDs
|
||||
* @param {object} options
|
||||
* @param {object} options.adapterOptions
|
||||
* @return {Promise}
|
||||
*/
|
||||
removeInjectedApplicationCredentialSources(
|
||||
injectedApplicationCredentialSourceIDs,
|
||||
options = { adapterOptions: {} }
|
||||
) {
|
||||
const defaultAdapterOptions = {
|
||||
method: 'remove-credential-sources',
|
||||
injectedApplicationCredentialSourceIDs,
|
||||
};
|
||||
// There is no "deep merge" in ES.
|
||||
return this.save({
|
||||
...options,
|
||||
adapterOptions: {
|
||||
...defaultAdapterOptions,
|
||||
...options.adapterOptions,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a single credential library/credential set via the `remove-credential-sources` method.
|
||||
* @param {number} injectedApplicationCredentialSourceID
|
||||
* @param {object} options
|
||||
* @return {Promise}
|
||||
*/
|
||||
removeInjectedApplicationCredentialSource(
|
||||
injectedApplicationCredentialSourceID,
|
||||
options
|
||||
) {
|
||||
return this.removeInjectedApplicationCredentialSources(
|
||||
[injectedApplicationCredentialSourceID],
|
||||
options
|
||||
);
|
||||
}
|
||||
/**
|
||||
* True if the target type is tcp.
|
||||
* @type {boolean}
|
||||
|
||||
Reference in new issue
Block a user