-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sichan Yoo
committed
Aug 14, 2023
1 parent
0224534
commit 33a6aaa
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
Sources/Core/AWSClientRuntime/Auth/CredentialsProviders/SSOCredentialsProvider.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import AwsCommonRuntimeKit | ||
import ClientRuntime | ||
import Foundation | ||
|
||
/// Creates a provider that that sources credentials using GetRoleCredentialsRequest to the AWS Single | ||
/// Sign-On Service to maintain short-lived sessions. | ||
/// [Details link](https://docs.aws.amazon.com/sdkref/latest/guide/feature-sso-credentials.html) | ||
/// - Parameters: | ||
/// - bootstrap: Connection bootstrap to use for any network connections made while sourcing credentials. | ||
/// - tlsContext: Client TLS context to use when querying STS web identity provider. | ||
/// - fileBasedConfiguration: The file based configuration to read the configuration from. | ||
/// - profileFileNameOverride: (Optional) Override of what profile to use to source credentials from ('default' by default) | ||
/// - shutdownCallback: (Optional) shutdown callback | ||
/// - Returns: `CredentialsProvider` | ||
/// - Throws: CommonRuntimeError.crtError | ||
/// | ||
public struct SSOCredentialsProvider: CredentialsSourcedByCRT { | ||
let crtCredentialsProvider: CRTCredentialsProvider | ||
public init( | ||
profileName: String? = nil, | ||
configFilePath: String? = nil, | ||
credentialsFilePath: String? = nil | ||
) throws { | ||
let fileBasedConfig = try CRTFileBasedConfiguration( | ||
configFilePath: configFilePath, | ||
credentialsFilePath: credentialsFilePath | ||
) | ||
self.crtCredentialsProvider = try CRTCredentialsProvider(source: .process( | ||
fileBasedConfiguration: fileBasedConfig, | ||
profileFileNameOverride: profileName | ||
)) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...re/AWSClientRuntimeTests/Auth/CredentialsProvidersTests/SSOCredentialsProviderTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters