Skip to content

Commit f6816a0

Browse files
committed
federated ssm
1 parent 3d448d4 commit f6816a0

File tree

9 files changed

+44
-20
lines changed

9 files changed

+44
-20
lines changed

package-lock.json

Lines changed: 15 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
"email": "paolo.diciaula@besharp.it"
1717
},
1818
{
19-
"name" : "Eric Villa",
20-
"email": "eric@noovolari.com"
19+
"name": "Eric Villa",
20+
"email": "eric@noovolari.com"
2121
},
2222
{
23-
"name": "Andrea Cavagna",
24-
"email": "andrea.cavagna@noovolari.com"
23+
"name": "Andrea Cavagna",
24+
"email": "andrea.cavagna@noovolari.com"
2525
}
2626
],
2727
"repository": "https://github.com/Noovolari/leapp",
@@ -198,7 +198,7 @@
198198
"@types/jasminewd2": "~2.0.3",
199199
"@types/node": "^10.17.27",
200200
"codelyzer": "^5.2.2",
201-
"electron": "8.5.2",
201+
"electron": "^8.5.2",
202202
"electron-builder": "^22.7.0",
203203
"electron-builder-squirrel-windows": "^21.1.3",
204204
"electron-installer-dmg": "^3.0.0",

src/app/app.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ export class AppComponent implements OnInit {
4848

4949
// Prevent Dev Tool to show on production mode
5050
this.app.currentBrowserWindow().webContents.on('devtools-opened', () => {
51-
// if (environment.production) {
51+
if (environment.production) {
5252
this.app.currentBrowserWindow().webContents.closeDevTools();
53-
// }
53+
}
5454
});
5555

5656
// We get the right moment to set an hook to app close

src/app/models/strategies/awsStrategy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ export class AwsStrategy extends RefreshCredentialsStrategy {
6060
const secretKey = await this.keychainService.getSecret(environment.appName, this.appService.keychainGenerateSecretString(session.account.accountName, (session.account as AwsPlainAccount).user));
6161
const credentials = {default: {aws_access_key_id: accessKey, aws_secret_access_key: secretKey}};
6262

63+
workspace.ssmCredentials = credentials;
64+
this.configurationService.updateWorkspaceSync(workspace);
65+
6366
this.fileService.iniWriteSync(this.appService.awsCredentialPath(), credentials);
6467
this.configurationService.disableLoadingWhenReady(workspace, session);
6568
}

src/app/models/workspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ export interface Workspace {
1313
azureProfile: string;
1414

1515
sessions: Session[];
16-
awsCredentials?: AwsCredentials;
16+
ssmCredentials?: any;
1717
}

src/app/services/ssm.service.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,19 @@ export class SsmService {
147147
* @param data - the credential information
148148
* @param region - the region for the client
149149
*/
150-
setConfig(data: { default: AwsCredential }, region) {
151-
return {
150+
setConfig(data: AwsCredential , region) {
151+
152+
return data.aws_session_token ? {
153+
region,
154+
credentials: {
155+
accessKeyId: data.aws_access_key_id,
156+
secretAccessKey: data.aws_secret_access_key,
157+
sessionToken: data.aws_session_token
158+
}} : {
152159
region,
153160
credentials: {
154-
accessKeyId: data.default.aws_access_key_id,
155-
secretAccessKey: data.default.aws_secret_access_key,
156-
sessionToken: data.default.aws_session_token
161+
accessKeyId: data.aws_access_key_id,
162+
secretAccessKey: data.aws_secret_access_key
157163
}};
158164
}
159165
}

src/app/services/workspace.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,9 @@ export class WorkspaceService extends NativeService {
411411
credential.aws_secret_access_key = secretAccessKey;
412412
credential.aws_session_token = sessionToken;
413413

414+
workspace.ssmCredentials = credential;
415+
this.configurationService.updateWorkspaceSync(workspace);
416+
414417
// Return it!
415418
return {default: credential};
416419
}

src/app/session/session-card/session-card.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<a dropdownToggle class="drop-list-container" aria-controls="drop-list" (click)="openDropDown($event);"><i
88
class="fa fa-ellipsis-v"></i></a>
99
<div id="drop-list" *dropdownMenu class="dropdown-menu drop-list dropdown-menu-right" role="menu" aria-labelledby="button-basic">
10-
<a (click)="ssmModalOpen(session, $event);" *ngIf="(session.account.type === eAccountType.AWS || session.account.type === eAccountType.AWS_PLAIN_USER) && session.active">SSM session</a>
10+
<a (click)="ssmModalOpen(session, $event);" *ngIf="(session.account.type === eAccountType.AWS) && session.active">SSM session</a>
1111
<a (click)="removeAccount(session, $event);">Remove account</a>
1212
<ng-container *ngIf="session.account.type === eAccountType.AWS">
1313
<a (click)="copyCredentials(session, 1, $event);">Copy Account Number</a>
@@ -24,7 +24,7 @@
2424
<ng-template #ssmModalTemplate>
2525
<div class="modal-header">
2626
<button type="button" class="back" aria-label="Close" (click)="modalRef.hide();"><i class="fa fa-arrow-left"></i></button>
27-
<b>{{session.account.accountName}}</b> - {{$any(session.account).role.name}} | <b>SSM</b>
27+
<b>{{session.account.accountName}}</b> - {{$any(session.account).role ? $any(session.account).role.name : 'Plain' }} | <b>SSM</b>
2828
</div>
2929
<div class="modal-body">
3030

src/app/session/session-card/session-card.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ export class SessionCardComponent implements OnInit {
181181
if (this.selectedSsmRegion) {
182182
this.ssmloading = true;
183183
// Set the aws credentials to instanziate the ssm client
184-
const credentials = this.configurationService.getDefaultWorkspaceSync().awsCredentials;
184+
const credentials = this.configurationService.getDefaultWorkspaceSync().ssmCredentials;
185+
185186
// Check the result of the call
186187
this.ssmService.setInfo(credentials, this.selectedSsmRegion).subscribe(result => {
187188
this.instances = result.instances;

0 commit comments

Comments
 (0)