Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow defining iam role session name #155

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/tutorials/aws/iam_chained_role/setup_in_leapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Select "**IAM Chained Role**" as the Access Strategy.
- **Session Alias:** choose a unique name suitable to recognize the Access Method.
- **Region**: the region to start this credential set into once the section is active. You can always add a default one from option panel
- **Role ARN**: Write the role ARN of the chained role you want to assume inside your AWS Account.
- **Role Session Name**: Optional Role Session Name to apply to the chained session. Defaults to `assumed-from-leapp`
- **Assumer Session**: any eligible session that you can use to start your chained session.

Finally press **Save**.
4 changes: 2 additions & 2 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ const ipc = ipcMain;
app.allowRendererProcessReuse = true;
app.disableHardwareAcceleration();

// Main Window configuration: set here tyhe options to make it works with your app
// Main Window configuration: set here the options to make it works with your app
// Electron is the application wrapper so NOT log is prompted when we build an
// application, we need to log to a file instead
const windowDefaultConfig = {
dir: path.join(__dirname, `/../../../dist/leapp-client`),
browserWindow: {
width: 514,
height: 600,
height: 650,
title: ``,
icon: path.join(__dirname, `assets/images/Leapp.png`),
resizable: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ <h2>Add credentials</h2>
<!-- ================================================================== -->
<ng-container *ngIf="sessionType === eSessionType.awsIamRoleChained">
<h2>IAM Role Chained setting</h2>
<div class="form-group" style="width: 100%; display: inline-block; position: relative; top: -1px;" >
<label>Role Session Name</label>
<input formControlName="roleSessionName" type="text" class="form-control" placeholder="Role Session Name" />
<small class="text-error" *ngIf="(form.controls['roleSessionName'].dirty || form.controls['roleSessionName'].touched) && form.controls['roleSessionName'].errors">Invalid Role Session Name</small>
</div>
<div class="form-group" style="width: 100%; display: inline-block; position: relative; top: -1px;" >
<label style="margin-bottom: 0;">Assumer Session<span class="danger-text">*</span> <i class="fa fa-question-circle" tooltip="Source Session to assume the current Session"></i></label>
<ng-select class="mt-2" formControlName="assumerSession" bindLabel="sessionName" bindValue="session" dropdownPosition="top" [items]="assumerAwsSessions" [(ngModel)]="selectedSession" [disabled]="true"></ng-select>
Expand Down
2 changes: 2 additions & 0 deletions src/app/components/create-account/create-account.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class CreateAccountComponent implements OnInit {
name: new FormControl('', [Validators.required]),
role: new FormControl('', [Validators.required]),
roleArn: new FormControl('', [Validators.required]),
roleSessionName: new FormControl('', [Validators.pattern('[a-zA-Z\\d\\-\\_\\@\\=\\,\\.]+')]),
federatedOrIamRoleChained: new FormControl('', [Validators.required]),
federatedRole: new FormControl('', [Validators.required]),
federationUrl: new FormControl('', [Validators.required, Validators.pattern('https?://.+')]),
Expand Down Expand Up @@ -259,6 +260,7 @@ export class CreateAccountComponent implements OnInit {
accountName: this.form.value.name.trim(),
region: this.selectedRegion,
roleArn: this.form.value.roleArn.trim(),
roleSessionName: this.form.value.roleSessionName.trim(),
parentSessionId: this.selectedSession.sessionId
};
this.awsIamRoleChainedService.create(awsIamRoleChainedAccountRequest, this.selectedProfile.value);
Expand Down
4 changes: 3 additions & 1 deletion src/app/models/aws-iam-role-chained-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ export class AwsIamRoleChainedSession extends Session {
roleArn: string;
profileId: string;
parentSessionId: string;
roleSessionName?: string;

constructor(sessionName: string, region: string, roleArn: string, profileId: string, parentSessionId: string) {
constructor(sessionName: string, region: string, roleArn: string, profileId: string, parentSessionId: string, roleSessionName?: string) {
super(sessionName, region);

this.roleArn = roleArn;
this.profileId = profileId;
this.parentSessionId = parentSessionId;
this.type = SessionType.awsIamRoleChained;
this.roleSessionName = roleSessionName ? roleSessionName : `assumed-from-leapp`;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface AwsIamRoleChainedSessionRequest {
accountName: string;
region: string;
roleArn: string;
roleSessionName?: string;
parentSessionId: string;
}

Expand Down Expand Up @@ -50,7 +51,7 @@ export class AwsIamRoleChainedService extends AwsSessionService {
}

create(sessionRequest: AwsIamRoleChainedSessionRequest, profileId: string): void {
const session = new AwsIamRoleChainedSession(sessionRequest.accountName, sessionRequest.region, sessionRequest.roleArn, profileId, sessionRequest.parentSessionId);
const session = new AwsIamRoleChainedSession(sessionRequest.accountName, sessionRequest.region, sessionRequest.roleArn, profileId, sessionRequest.parentSessionId, sessionRequest.roleSessionName);
this.workspaceService.addSession(session);
}

Expand Down Expand Up @@ -115,7 +116,7 @@ export class AwsIamRoleChainedService extends AwsSessionService {
// Configure IamRoleChained Account session parameters
const params = {
// eslint-disable-next-line @typescript-eslint/naming-convention
RoleSessionName: `assumed-from-leapp`,
RoleSessionName: (session as AwsIamRoleChainedSession).roleSessionName,
// eslint-disable-next-line @typescript-eslint/naming-convention
RoleArn: (session as AwsIamRoleChainedSession).roleArn,
};
Expand Down