Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
30e52bf
feat(aws): add support for AWS IAM Identity Center (SSO)
rjwhitworth May 9, 2026
b90170b
fix(aws): harden AWS SSO importer and provisioner against hostile inputs
rjwhitworth May 9, 2026
781ba27
fix(aws): accept GovCloud SSO regions and profile-aware login errors
scottisloud Jun 2, 2026
65f614e
removing embedded field
scottisloud Jun 2, 2026
a42e172
fix(aws): mark Access Key and SSO Profile as optional credential usages
rr3khan Jul 6, 2026
fac5e1e
fix(aws): accept SSO regions with prefixes longer than two letters
rr3khan Jul 6, 2026
e8accd8
fix(aws): restore SSO guard for source profiles in role chains
rr3khan Jul 6, 2026
e0e0396
Merge remote-tracking branch 'upstream/main' into rr3khan/feat/aws-ss…
rr3khan Nov 17, 2026
dde68e3
fix(aws): bump SSO and credentials modules to match the AWS SDK core
rr3khan Nov 17, 2026
3c83892
fix(aws): keep the selected profile as AWS_PROFILE when a provisioner…
rr3khan Nov 17, 2026
501ae51
fix(aws): keep the plugin compiling for Windows
rr3khan Nov 18, 2026
b604642
docs(aws): attach the SSO error translation comment to its function
rr3khan Nov 18, 2026
6e8f6aa
docs(aws): note the awslogs limitation when both credentials are conf…
rr3khan Nov 18, 2026
f5153f3
fix(aws): refresh expired SSO access tokens for sso-session profiles
rr3khan Nov 18, 2026
5d3602f
fix(aws): keep the `aws sso login` hint when a session login cannot b…
rr3khan Nov 18, 2026
8de2245
fix(aws): stop using cached SSO role credentials after `aws sso logout`
rr3khan Nov 24, 2026
2ba82a5
fix(aws): do not treat a profile as SSO because the default profile is
rr3khan Nov 24, 2026
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
24 changes: 12 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ require (
github.com/99designs/keyring v1.2.2
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/BurntSushi/toml v1.6.0
github.com/aws/aws-sdk-go-v2 v1.47.8
github.com/aws/aws-sdk-go-v2/service/sts v1.51.9
github.com/aws/aws-sdk-go-v2 v1.48.0
github.com/aws/aws-sdk-go-v2/service/sts v1.52.0
github.com/fatih/color v1.19.0
github.com/hashicorp/go-plugin v1.8.0
github.com/stretchr/testify v1.12.1
Expand All @@ -20,8 +20,8 @@ require (
)

require (
github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.11 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.24 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.12 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.25 // indirect
go.yaml.in/yaml/v3 v3.0.5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/protobuf v1.36.6 // indirect
Expand All @@ -33,16 +33,16 @@ require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/aws/aws-sdk-go-v2/config v1.18.15 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.15 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.23 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.11 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.11 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.21.1
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.9 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.12 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.12 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.30 // indirect
github.com/aws/aws-sdk-go-v2/service/iam v1.19.4 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.11 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.12.4 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.4 // indirect
github.com/aws/smithy-go v1.28.8 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.12 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.39.5
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.5
github.com/aws/smithy-go v1.28.9
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
Expand Down
44 changes: 24 additions & 20 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,45 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc=
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
github.com/aws/aws-sdk-go-v2 v1.17.5/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw=
github.com/aws/aws-sdk-go-v2 v1.47.8 h1:fuClo7Un+Bi0EDTnSIPWxVEoJcze+wkGzNA4Vo3jRcQ=
github.com/aws/aws-sdk-go-v2 v1.47.8/go.mod h1:I8lFSH4MGrZiw2m7miCrRYHsgpC1+HW8uiVGOiPYPcw=
github.com/aws/aws-sdk-go-v2 v1.48.0 h1:tFU7EJVm7MfyaXLsXdYTZ0Vd6vwt9OljCyqq0gqk0Mc=
github.com/aws/aws-sdk-go-v2 v1.48.0/go.mod h1:oeKU5p+TQBnpeLmU42WZLWvzv+ORLn+74n4QVLnm/Z0=
github.com/aws/aws-sdk-go-v2/config v1.18.15 h1:509yMO0pJUGUugBP2H9FOFyV+7Mz7sRR+snfDN5W4NY=
github.com/aws/aws-sdk-go-v2/config v1.18.15/go.mod h1:vS0tddZqpE8cD9CyW0/kITHF5Bq2QasW9Y1DFHD//O0=
github.com/aws/aws-sdk-go-v2/credentials v1.13.15 h1:0rZQIi6deJFjOEgHI9HI2eZcLPPEGQPictX66oRFLL8=
github.com/aws/aws-sdk-go-v2/credentials v1.13.15/go.mod h1:vRMLMD3/rXU+o6j2MW5YefrGMBmdTvkLLGqFwMLBHQc=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.23 h1:Kbiv9PGnQfG/imNI4L/heyUXvzKmcWSBeDvkrQz5pFc=
github.com/aws/aws-sdk-go-v2/credentials v1.21.1 h1:4iuMmYSa42WMeClXjzE+HoZIeBud6o/bd00BN6WM9H4=
github.com/aws/aws-sdk-go-v2/credentials v1.21.1/go.mod h1:OffaVQod3fyZzhZJyPtw11WpHPF1uIHADc+/MYlXmbA=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.23/go.mod h1:mOtmAg65GT1HIL/HT/PynwPbS+UG0BgCZ6vhkPqnxWo=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.9 h1:oH1E0tjN0g+ZRusbX1dsuat4FJ0z05l8hWaycSbDuNc=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.9/go.mod h1:3ZaQGigIoaS45x9HgnLZ4sP475Fs7QoxU3IsZX/J3h4=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.29/go.mod h1:Dip3sIGv485+xerzVv24emnjX5Sg88utCL8fwGmCeWg=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.11 h1:LTxHSJ/rwTFfaXqi5mlKKHJOW+shFB+HQ7NrCa4OQ48=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.11/go.mod h1:GF0bVKZVQX4UeUtPmTuWZj3gw0eRCdkVhW0xFnSRLmU=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.12 h1:W0yUUzKBA8SofGQ0yZafEUuZq9UxfvijRgdc6vcRQPA=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.12/go.mod h1:xwKv6vwBNdpPFOxEm/ld4IODZK2s/1ksHvdBqLfH6Gs=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.23/go.mod h1:mr6c4cHC+S/MMkrjtSlG4QA36kOznDep+0fga5L/fGQ=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.11 h1:DGUM0yztI3Zz5kePulT/mMP/gVZFGTTISUiCcqSQtT0=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.11/go.mod h1:kbcdJgN9cgSzZlUqsMveDl9IfexJqOzCihXjQXTNaPk=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.12 h1:lqSi8qvAnKC1vfosImdmOsuiJLr/jdybZX5299beB6Q=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.12/go.mod h1:rqPQE2vqkW9YHx5+Gp55sx1wsTM4xtGQLl+TKMjxxrs=
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.30 h1:IVx9L7YFhpPq0tTnGo8u8TpluFu7nAn9X3sUDMb11c0=
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.30/go.mod h1:vsbq62AOBwQ1LJ/GWKFxX8beUEYeRp/Agitrxee2/qM=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.11 h1:kOHCwgWFyfrz9GqnJct8knQw7Apyl3xHH+OGnome77s=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.11/go.mod h1:854cZkT2fdkdrzQklD49uzxkZnajXoelpVNgT/yk4J0=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.12 h1:uvX2yaL+aMjkmnrLPPlR/zwjoKFRMoNhhJfeGjfk6qc=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.12/go.mod h1:dicT+2eNhHHqGkxHO7LoXw3QghIUGuzgdmFqaSTopgI=
github.com/aws/aws-sdk-go-v2/service/iam v1.19.4 h1:hrBxgoUih7uy9sJTXrX0N/3TVgbmevlxEYsP9l+Lje4=
github.com/aws/aws-sdk-go-v2/service/iam v1.19.4/go.mod h1:F5Xt96+AfAiyMpRXHy9CKafE/KULVwj7MwgZ0a4row4=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.24 h1:jGzHjc2jDx08Rji1JTBtMxuXUDG7muTEw+ExYXqFzPg=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.24/go.mod h1:uJt75pK2cEyY80F5C+DK9YkCkJWsMkJViHxLYZRHl8Y=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.25 h1:rKwkY3Z+fvt2W0msjdNs6uNewPmXzPayQ961oyuWhes=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.25/go.mod h1:dBuAadQKd1F4Q4ZOg8gnFmuSHMRE40Pe3IfFwbtC4lE=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.23/go.mod h1:9uPh+Hrz2Vn6oMnQYiUi/zbh3ovbnQk19YKINkQny44=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.11 h1:PO7Tx443ecMI00nIxDrT99DVcbeMBQ6BUtJlDMRnY24=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.11/go.mod h1:n/9RixikO12YvNomZLP8k4TgUSoEkT1W23QIrpFAPvw=
github.com/aws/aws-sdk-go-v2/service/sso v1.12.4 h1:qJdM48OOLl1FBSzI7ZrA1ZfLwOyCYqkXV5lko1hYDBw=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.12 h1:wzAqMZ2O4+ij9HQqIrk+P9PBGacE0wOTuWB7Mo97//I=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.12/go.mod h1:/0TfyruByHsOlphzP26xDTRe2DKD0J1I1Uyy2TyP8EI=
github.com/aws/aws-sdk-go-v2/service/sso v1.12.4/go.mod h1:jtLIhd+V+lft6ktxpItycqHqiVXrPIRjWIsFIlzMriw=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.4 h1:YRkWXQveFb0tFC0TLktmmhGsOcCgLwvq88MC2al47AA=
github.com/aws/aws-sdk-go-v2/service/sso v1.39.5 h1:ANAoa+qt3/9kXnvQVgUyxcTzhzZf4DqaBS+M2DQrELU=
github.com/aws/aws-sdk-go-v2/service/sso v1.39.5/go.mod h1:vsMi+SSR7xGQXtV430LVi49qbv/R+U+upHHSp1W/+QI=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.4/go.mod h1:zVwRrfdSmbRZWkUkWjOItY7SOalnFnq/Yg2LVPqDjwc=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.5 h1:uIOBLMhef4N16WguadoHKuBy9etdz+RKTeqzchXErAI=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.5/go.mod h1:NwWmkFLtsTVyXQpbzPOlYLwEoANkdCFjJRtrNcbg/vY=
github.com/aws/aws-sdk-go-v2/service/sts v1.18.5/go.mod h1:1mKZHLLpDMHTNSYPJ7qrcnCQdHCWsNQaT0xRvq2u80s=
github.com/aws/aws-sdk-go-v2/service/sts v1.51.9 h1:soG/8YBczEJwckK+e4HLt0RzfkvopGrdBjmbghG99Cc=
github.com/aws/aws-sdk-go-v2/service/sts v1.51.9/go.mod h1:We33qfrD3dQRAetZ+9qUH9w+ZjL1gwP2Qvp1YqQDdsk=
github.com/aws/aws-sdk-go-v2/service/sts v1.52.0 h1:IaBLmJWiIEtKkjXMgMbYGZk7WKXbYA8148wCMCXq9hU=
github.com/aws/aws-sdk-go-v2/service/sts v1.52.0/go.mod h1:MG6N8U9+lY4LqchrlHPqCOSr7hyxw70XU0Et2YR3eNA=
github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
github.com/aws/smithy-go v1.28.8 h1:aEmdAq7gVCoGCnvf1NnELlu3I6D/nhqrC321FyFiQkQ=
github.com/aws/smithy-go v1.28.8/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
github.com/aws/smithy-go v1.28.9 h1:zkZ058OpNX0iGTK24b+ZUEQSMc11CBA6oO7xtKZfzkY=
github.com/aws/smithy-go v1.28.9/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw=
github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c=
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
Expand Down
122 changes: 122 additions & 0 deletions plugins/aws/access_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,128 @@ func TestSourceProfileLoop(t *testing.T) {
})
}

func TestSTSProvisionerYieldsOnSSOProfile(t *testing.T) {
t.Setenv("AWS_PROFILE", "")
t.Setenv("AWS_DEFAULT_REGION", "")
configPath := filepath.Join(t.TempDir(), "awsConfig")
t.Setenv("AWS_CONFIG_FILE", configPath)

file := ini.Empty()

profileLegacy, err := file.NewSection("profile sso-legacy")
require.NoError(t, err)
_, err = profileLegacy.NewKey("sso_start_url", "https://example.awsapps.com/start")
require.NoError(t, err)
_, err = profileLegacy.NewKey("sso_region", "us-east-1")
require.NoError(t, err)
_, err = profileLegacy.NewKey("sso_account_id", "111111111111")
require.NoError(t, err)
_, err = profileLegacy.NewKey("sso_role_name", "ReadOnly")
require.NoError(t, err)

ssoSession, err := file.NewSection("sso-session corp")
require.NoError(t, err)
_, err = ssoSession.NewKey("sso_start_url", "https://corp.awsapps.com/start")
require.NoError(t, err)
_, err = ssoSession.NewKey("sso_region", "eu-west-1")
require.NoError(t, err)

profileSession, err := file.NewSection("profile sso-new")
require.NoError(t, err)
_, err = profileSession.NewKey("sso_session", "corp")
require.NoError(t, err)
_, err = profileSession.NewKey("sso_account_id", "222222222222")
require.NoError(t, err)
_, err = profileSession.NewKey("sso_role_name", "PowerUser")
require.NoError(t, err)

err = file.SaveTo(configPath)
require.NoError(t, err)

// When the active profile is SSO-configured, the STS provisioner must yield
// silently — no env vars, no error — so the SSO Profile provisioner can run.
plugintest.TestProvisioner(t, STSProvisioner{
profileName: "sso-legacy",
newProviderFactory: func(cacheState sdk.CacheState, cacheOps sdk.CacheOperations, fields map[sdk.FieldName]string) STSProviderFactory {
return &mockProviderManager{}
},
}, map[string]plugintest.ProvisionCase{
"legacy SSO profile yields silently": {
ItemFields: map[sdk.FieldName]string{
fieldname.AccessKeyID: "AKIAHPIZFMD5EEXAMPLE",
fieldname.SecretAccessKey: "lBfKB7P5ScmpxDeRoFLZvhJbqNGPoV0vIEXAMPLE",
},
ExpectedOutput: sdk.ProvisionOutput{},
},
})

plugintest.TestProvisioner(t, STSProvisioner{
profileName: "sso-new",
newProviderFactory: func(cacheState sdk.CacheState, cacheOps sdk.CacheOperations, fields map[sdk.FieldName]string) STSProviderFactory {
return &mockProviderManager{}
},
}, map[string]plugintest.ProvisionCase{
"sso_session profile yields silently": {
ItemFields: map[sdk.FieldName]string{
fieldname.AccessKeyID: "AKIAHPIZFMD5EEXAMPLE",
fieldname.SecretAccessKey: "lBfKB7P5ScmpxDeRoFLZvhJbqNGPoV0vIEXAMPLE",
},
ExpectedOutput: sdk.ProvisionOutput{},
},
})
}

func TestSTSProvisionerErrorsOnSSOSourceProfile(t *testing.T) {
t.Setenv("AWS_PROFILE", "")
t.Setenv("AWS_DEFAULT_REGION", "")
configPath := filepath.Join(t.TempDir(), "awsConfig")
t.Setenv("AWS_CONFIG_FILE", configPath)

file := ini.Empty()

ssoSource, err := file.NewSection("profile sso-src")
require.NoError(t, err)
_, err = ssoSource.NewKey("sso_start_url", "https://example.awsapps.com/start")
require.NoError(t, err)
_, err = ssoSource.NewKey("sso_region", "us-east-1")
require.NoError(t, err)
_, err = ssoSource.NewKey("sso_account_id", "111111111111")
require.NoError(t, err)
_, err = ssoSource.NewKey("sso_role_name", "ReadOnly")
require.NoError(t, err)

chained, err := file.NewSection("profile chained")
require.NoError(t, err)
_, err = chained.NewKey("role_arn", "arn:aws:iam::111111111111:role/Chained")
require.NoError(t, err)
_, err = chained.NewKey("source_profile", "sso-src")
require.NoError(t, err)

err = file.SaveTo(configPath)
require.NoError(t, err)

// A role-chain profile whose source profile is SSO-configured is handled by neither
// provisioner: the top-level profile is not SSO, so the SSO provisioner yields, and the
// source profile has no long-lived keys. The STS provisioner must surface a clear error
// rather than failing later with a misleading missing-access-key message.
plugintest.TestProvisioner(t, STSProvisioner{
profileName: "chained",
newProviderFactory: func(cacheState sdk.CacheState, cacheOps sdk.CacheOperations, fields map[sdk.FieldName]string) STSProviderFactory {
return &mockProviderManager{}
},
}, map[string]plugintest.ProvisionCase{
"SSO source profile in role chain errors clearly": {
ItemFields: map[sdk.FieldName]string{
fieldname.AccessKeyID: "AKIAHPIZFMD5EEXAMPLE",
fieldname.SecretAccessKey: "lBfKB7P5ScmpxDeRoFLZvhJbqNGPoV0vIEXAMPLE",
},
ExpectedOutput: sdk.ProvisionOutput{
Diagnostics: sdk.Diagnostics{Errors: []sdk.Error{{Message: `profile "sso-src" is configured for AWS IAM Identity Center (SSO) and is not yet supported as the source profile of a role chain by the AWS Shell Plugin`}}},
},
},
})
}

func TestResolveLocalAnd1PasswordConfigurations(t *testing.T) {
for _, scenario := range []struct {
description string
Expand Down
32 changes: 32 additions & 0 deletions plugins/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,43 @@ func AWSCLI() schema.Executable {
NeedsAuth: needsauth.IfAll(
needsauth.NotForHelpOrVersion(),
needsauth.NotWithoutArgs(),
// Each entry below intentionally bypasses provisioning. Subcommands not listed here
// (e.g. `aws configure import`, `aws configure export-credentials`) still flow through
// the provisioner because they exchange or mutate credentials and benefit from the
// 1Password-managed surface.
//
// `aws sso login`/`logout` write/erase the very token the SSO Profile provisioner reads
// from disk; provisioning before they run creates a chicken-and-egg failure.
needsauth.NotWhenContainsArgs("sso", "login"),
needsauth.NotWhenContainsArgs("sso", "logout"),
// `aws configure sso` and `aws configure sso-session` set up SSO configuration in
// ~/.aws/config; they touch no AWS APIs and need no provisioned credentials.
needsauth.NotWhenContainsArgs("configure", "sso"),
needsauth.NotWhenContainsArgs("configure", "sso-session"),
// `aws configure list` and `list-profiles` are read-only diagnostic queries against
// the local config; `get` and `set` mutate ~/.aws/config or ~/.aws/credentials but
// make no remote API call. Provisioning would be a no-op at best and a confusing
// "missing credentials" error at worst when the user is just inspecting state.
needsauth.NotWhenContainsArgs("configure", "list"),
needsauth.NotWhenContainsArgs("configure", "list-profiles"),
needsauth.NotWhenContainsArgs("configure", "get"),
needsauth.NotWhenContainsArgs("configure", "set"),
),
Uses: []schema.CredentialUsage{
// Both credential types are optional so that users can link only the one
// they use: SSO-only users (no IAM access key) can set up the plugin without
// being forced to provide an Access Key, and vice versa. At runtime, each
// provisioner yields silently when the active profile is configured for the
// other credential type.
{
Name: credname.AccessKey,
Provisioner: CLIProvisioner{},
Optional: true,
},
{
Name: credname.SSOProfile,
Provisioner: SSOCLIProvisioner{},
Optional: true,
},
},
}
Expand Down
11 changes: 11 additions & 0 deletions plugins/aws/awslogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,21 @@ func awslogsCLI() schema.Executable {
needsauth.NotForHelpOrVersion(),
needsauth.NotWithoutArgs(),
),
// Known limitation when both credentials are configured: awslogs treats AWS_PROFILE as an explicitly
// selected profile and then ignores credentials in the environment. With `--profile <access key profile>`,
// the SSO Profile provisioner yields and keeps the profile as AWS_PROFILE, so awslogs looks for credentials
// in that profile instead of using the Access Key that was provisioned. Setups with a single credential are
// not affected.
Uses: []schema.CredentialUsage{
{
Name: credname.AccessKey,
Provisioner: CLIProvisioner{},
Optional: true,
},
{
Name: credname.SSOProfile,
Provisioner: SSOCLIProvisioner{},
Optional: true,
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions plugins/aws/cache_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
const (
mfaCacheKeyID = "sts-mfa"
assumeRoleCacheKeyID = "sts-assume-role"
ssoRoleCacheKeyID = "sso-role"
)

// stsCacheWriter writes aws temp credentials to cache using the awsCacheKey
Expand All @@ -36,3 +37,7 @@ func getRoleCacheKey(roleArn string, accessKeyID string) string {
func getMfaCacheKey(accessKeyID string) string {
return fmt.Sprintf("%s|%s", mfaCacheKeyID, accessKeyID)
}

func getSSORoleCacheKey(accountID, roleName, sessionKey string) string {
return fmt.Sprintf("%s|%s|%s|%s", ssoRoleCacheKeyID, accountID, roleName, sessionKey)
}
6 changes: 6 additions & 0 deletions plugins/aws/cdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ func AWSCDKToolkit() schema.Executable {
{
Name: credname.AccessKey,
Provisioner: CLIProvisioner{},
Optional: true,
},
{
Name: credname.SSOProfile,
Provisioner: SSOCLIProvisioner{},
Optional: true,
},
},
}
Expand Down
Loading