mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-30 18:17:55 +00:00 
			
		
		
		
	 67fc1fab4c
			
		
	
	67fc1fab4c
	
	
	
		
			
			* do not send ttl if unset for aws credentials * test coverage * remove comment * add changelog * Update aws test, cancel button is secondary
		
			
				
	
	
		
			37 lines
		
	
	
		
			996 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			996 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /**
 | |
|  * Copyright (c) HashiCorp, Inc.
 | |
|  * SPDX-License-Identifier: BUSL-1.1
 | |
|  */
 | |
| 
 | |
| import ApplicationAdapter from './application';
 | |
| 
 | |
| export default ApplicationAdapter.extend({
 | |
|   createRecord(store, type, snapshot) {
 | |
|     const ttl = snapshot.attr('ttl');
 | |
|     const roleArn = snapshot.attr('roleArn');
 | |
|     const roleType = snapshot.attr('credentialType');
 | |
|     let method = 'POST';
 | |
|     let options;
 | |
|     const data = {};
 | |
|     if (roleType === 'iam_user') {
 | |
|       method = 'GET';
 | |
|     } else {
 | |
|       if (ttl) {
 | |
|         data.ttl = ttl;
 | |
|       }
 | |
|       if (roleType === 'assumed_role' && roleArn) {
 | |
|         data.role_arn = roleArn;
 | |
|       }
 | |
|       options = data.ttl || data.role_arn ? { data } : {};
 | |
|     }
 | |
|     const role = snapshot.attr('role');
 | |
|     const url = `/v1/${role.backend}/creds/${role.name}`;
 | |
| 
 | |
|     return this.ajax(url, method, options).then((response) => {
 | |
|       response.id = snapshot.id;
 | |
|       response.modelName = type.modelName;
 | |
|       store.pushPayload(type.modelName, response);
 | |
|     });
 | |
|   },
 | |
| });
 |