Skip to content

Commit

Permalink
Improve exception when IAM Identity Center auth is used (#629)
Browse files Browse the repository at this point in the history
* Improve exception when IAM Identity Center auth is used

* Formatting

* Set project version to 1.87.1
  • Loading branch information
omus authored Jun 7, 2023
1 parent 1688679 commit 7b09eb1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AWS"
uuid = "fbe9abb3-538b-5e4e-ba9e-bc94f4f92ebc"
license = "MIT"
version = "1.87.0"
version = "1.87.1"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
11 changes: 11 additions & 0 deletions src/AWSCredentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,17 @@ function sso_credentials(profile=nothing)
settings = _aws_profile_config(ini, p)
isempty(settings) && return nothing

# AWS IAM Identity Center authentication is not yet supported in AWS.jl
sso_session = get(settings, "sso_session", nothing)
if !isnothing(sso_session)
error(
"IAM Identity Center authentication is not yet supported by AWS.jl. " *
"See https://github.com/JuliaCloud/AWS.jl/issues/628",
)
end

# Legacy SSO configuration
# https://docs.aws.amazon.com/cli/latest/userguide/sso-configure-profile-legacy.html#sso-configure-profile-manual
sso_start_url = get(settings, "sso_start_url", nothing)

if !isnothing(sso_start_url)
Expand Down
23 changes: 23 additions & 0 deletions test/AWSCredentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,29 @@ end
end
end

# TODO: Additional, precedence tests should be added for IAM Identity Center
# once support has been introduced.
@testset "IAM Identity Center preferred over legacy SSO" begin
write(
config_file,
"""
[sso-session my-sso]
sso_region = us-east-1
sso_start_url = https://my-sso-portal.awsapps.com/start
[default]
sso_session = my-sso
sso_start_url = https://my-legacy-sso-portal.awsapps.com/start
sso_role_name = role1
""",
)
isfile(creds_file) && rm(creds_file)

apply(Patches.sso_service_patches("AKI_SSO", "SAK_SSO")) do
@test_throws ErrorException AWSCredentials()
end
end

@testset "SSO preferred over credentials file" begin
write(
config_file,
Expand Down

2 comments on commit 7b09eb1

@omus
Copy link
Member Author

@omus omus commented on 7b09eb1 Jun 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/85081

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.87.1 -m "<description of version>" 7b09eb1e74f9582f55cda193d84ed1b666f68289
git push origin v1.87.1

Please sign in to comment.