-
-
Notifications
You must be signed in to change notification settings - Fork 283
feat(plugins): config profiles, credential_process, SSO, AssumeRole, ElastiCache, Keyspaces (#1567) #1572
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
Merged
Merged
feat(plugins): config profiles, credential_process, SSO, AssumeRole, ElastiCache, Keyspaces (#1567) #1572
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2467cbb
refactor(plugins): move AWS credential resolution into TableProPluginKit
datlechin 1d92f35
fix(plugin-dynamodb): resolve AWS profiles from ~/.aws/config and cre…
datlechin d35e48e
feat(connections): pick AWS profiles from a discovered list in the co…
datlechin 1e6a27e
feat(plugins): assume IAM roles via role_arn and source_profile (#1567)
datlechin d6c58cf
feat(plugin-redis): authenticate to ElastiCache with AWS IAM (#1567)
datlechin c349645
feat(connections): sign in to AWS SSO in-app when the session has exp…
datlechin 0fa10f0
feat(plugin-cassandra): authenticate to Amazon Keyspaces with AWS IAM…
datlechin 7b07814
refactor(plugins): keep ConnectionField init ABI-stable and harden AW…
datlechin 528052a
fix(plugin-cassandra): let Keyspaces resolve AWS IAM in the driver in…
datlechin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
66 changes: 66 additions & 0 deletions
66
Plugins/CassandraDriverPlugin/CassandraSigV4Authenticator.swift
This file contains hidden or 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,66 @@ | ||
| import CCassandra | ||
| import Foundation | ||
| import TableProPluginKit | ||
|
|
||
| final class CassandraSigV4Context { | ||
| let credentials: AWSCredentials | ||
| let region: String | ||
|
|
||
| init(credentials: AWSCredentials, region: String) { | ||
| self.credentials = credentials | ||
| self.region = region | ||
| } | ||
| } | ||
|
|
||
| enum CassandraSigV4Authenticator { | ||
| static func apply(to cluster: OpaquePointer, credentials: AWSCredentials, region: String) { | ||
| var callbacks = CassAuthenticatorCallbacks( | ||
| initial_callback: cassandraSigV4Initial, | ||
| challenge_callback: cassandraSigV4Challenge, | ||
| success_callback: nil, | ||
| cleanup_callback: nil | ||
| ) | ||
| let context = CassandraSigV4Context(credentials: credentials, region: region) | ||
| let data = Unmanaged.passRetained(context).toOpaque() | ||
| cass_cluster_set_authenticator_callbacks(cluster, &callbacks, cassandraSigV4DataCleanup, data) | ||
| } | ||
| } | ||
|
|
||
| private func cassandraSigV4Initial(_ auth: OpaquePointer?, _ data: UnsafeMutableRawPointer?) { | ||
| let bytes = Array(KeyspacesSigV4.initialResponse.utf8) | ||
| bytes.withUnsafeBytes { raw in | ||
| cass_authenticator_set_response(auth, raw.bindMemory(to: CChar.self).baseAddress, bytes.count) | ||
| } | ||
| } | ||
|
|
||
| private func cassandraSigV4Challenge( | ||
| _ auth: OpaquePointer?, | ||
| _ data: UnsafeMutableRawPointer?, | ||
| _ token: UnsafePointer<CChar>?, | ||
| _ tokenSize: Int | ||
| ) { | ||
| guard let data else { return } | ||
| let context = Unmanaged<CassandraSigV4Context>.fromOpaque(data).takeUnretainedValue() | ||
|
|
||
| let challenge: Data | ||
| if let token, tokenSize > 0 { | ||
| challenge = Data(bytes: token, count: tokenSize) | ||
| } else { | ||
| challenge = Data() | ||
| } | ||
| guard let nonce = KeyspacesSigV4.nonce(fromChallenge: challenge) else { return } | ||
|
|
||
| let response = KeyspacesSigV4.authResponse( | ||
| nonce: nonce, | ||
| credentials: context.credentials, | ||
| region: context.region | ||
| ) | ||
| response.withCString { pointer in | ||
| cass_authenticator_set_response(auth, pointer, strlen(pointer)) | ||
| } | ||
| } | ||
|
|
||
| private func cassandraSigV4DataCleanup(_ data: UnsafeMutableRawPointer?) { | ||
| guard let data else { return } | ||
| Unmanaged<CassandraSigV4Context>.fromOpaque(data).release() | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a DynamoDB SSO profile has a missing or expired token cache,
AWSCredentialResolverthrowsAWSSSOError, but this catch converts it intoDynamoDBError.authFailed. The test-connection flow only offers the browser sign-in path whenAWSSSOLoginService.isSSOExpired(error)receives anAWSSSOErrordirectly, so DynamoDB SSO users hit the generic connection failure instead of the new login prompt. Preserve the underlying SSO error (or teach the detector about this wrapper) for theawsAuthMethod == "sso"path.Useful? React with 👍 / 👎.