Skip to content

Commit

Permalink
fix(LEAP-371): fixed aws sso sessions synchronization logic
Browse files Browse the repository at this point in the history
  • Loading branch information
urz9999 committed Jan 25, 2022
1 parent a2d1349 commit fc09fce
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/app/components/integration/integration.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ export class IntegrationComponent implements OnInit, BrowserWindowClosing {
const region = this.form.get('awsRegion').value;
const browserOpening = this.form.get('defaultBrowserOpening').value;

console.log(portalUrl, region, browserOpening);

if(this.modifying === 1) {
// Save
this.workspaceService.addAwsSsoIntegration(
Expand Down
26 changes: 23 additions & 3 deletions src/app/services/aws-sso-integration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ export class AwsSsoIntegrationService {

for (let i = 0; i < persistedSessions.length; i++) {
const persistedSession = persistedSessions[i];
const shouldBeDeleted = sessions.indexOf(persistedSession as unknown as SsoRoleSession) === -1;
const shouldBeDeleted = sessions.filter(s =>
(persistedSession as unknown as SsoRoleSession).sessionName === s.sessionName &&
(persistedSession as unknown as SsoRoleSession).roleArn === s.roleArn &&
(persistedSession as unknown as SsoRoleSession).email === s.email).length === 0;

if (shouldBeDeleted) {
sessionsToBeDeleted.push(persistedSession as unknown as SsoRoleSession);
Expand All @@ -181,9 +184,26 @@ export class AwsSsoIntegrationService {
}
}

sessions = sessions.filter(session => !persistedSessions.includes(session as unknown as Session));
const finalSessions = [];

for (let j = 0; j < sessions.length; j++) {
const session = sessions[j];
let found = false;
for (let i = 0; i < persistedSessions.length; i++) {
const persistedSession = persistedSessions[i];
if((persistedSession as unknown as SsoRoleSession).sessionName === session.sessionName &&
(persistedSession as unknown as SsoRoleSession).roleArn === session.roleArn &&
(persistedSession as unknown as SsoRoleSession).email === session.email) {
found = true;
break;
}
}
if(!found) {
finalSessions.push(session);
}
}

return sessions;
return finalSessions;
}

async getAwsSsoIntegrationTokenInfo(awsSsoIntegrationId: string): Promise<AwsSsoIntegrationTokenInfo> {
Expand Down
2 changes: 0 additions & 2 deletions src/app/services/retrocompatibility.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,6 @@ export class RetrocompatibilityService {
(session as AwsIamUserSession).mfaDevice
);

console.log(workspace, workspace._profiles[0].id);

iamUserSession.sessionId = session.sessionId;

workspace._sessions.push(iamUserSession);
Expand Down

0 comments on commit fc09fce

Please sign in to comment.