Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
Open
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
7 changes: 5 additions & 2 deletions src/lib/extaws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ export class ExtAws {
* Main method for logging a user into AWS via Okta. Will log a user in and write credentials to aws profile
* @returns AWS Credentials
*/
async login(props?: { profile?: string, duration?: number, region?: string, role?: string }, inputSpinner?: Ora): Promise<STS.Types.AssumeRoleWithSAMLResponse> {
async login(props?: { profile?: string, duration?: number, region?: string, role?: string, team?: string, }, inputSpinner?: Ora): Promise<STS.Types.AssumeRoleWithSAMLResponse> {
const configResult = await ExtAws.getConfig()
if (configResult === null ) {
throw new Error('Missing configuration. Please `init`')
Expand Down Expand Up @@ -420,7 +420,10 @@ export class ExtAws {
if (props?.role) {
const needle = props.role
const searchResult = roles.filter(stsRole => {
return (~stsRole.role.indexOf(needle))
if(props?.team)
return (~stsRole.role.indexOf(needle))&&(~stsRole.role.indexOf(props.team))
else
return (~stsRole.role.indexOf(needle))
})[0]
if (searchResult !== undefined) {
userRole = searchResult
Expand Down
7 changes: 4 additions & 3 deletions src/lib/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ program
.option('-d --duration <durationSeconds>', 'Print a link rather than open a browser session', '43200')
.option('-r --region <awsRegion>', 'Region to set as default for the profile')
.option('-l --role <roleName>', 'Role to pick from SAML assertion. Prompts if not found')
.option('-t --team <teamName>', 'Team to pick from SAML assertion. Prompts if not found')
.parse(process.argv)

async function login(profile?: string | undefined, duration?: number | undefined, region?: string | undefined, role?: string | undefined) {
async function login(profile?: string | undefined, duration?: number | undefined, region?: string | undefined, role?: string | undefined, team?: string | undefined) {
const extaws = new ExtAws()
extaws.login({profile, duration, region, role})
extaws.login({profile, duration, region, role, team})
.catch(e => console.error(e))
}

Expand All @@ -24,5 +25,5 @@ if (program.duration) {
}
}

login(program.profile, duration, program.region, program.role)
login(program.profile, duration, program.region, program.role, program.team)