-
Notifications
You must be signed in to change notification settings - Fork 599
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
fix: enforce user must specify access_key and secret_key using aws auth #11120
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use aws_config::default_provider::credentials::DefaultCredentialsChain; | ||
use aws_config::default_provider::region::DefaultRegionChain; | ||
use aws_config::sts::AssumeRoleProvider; | ||
use aws_credential_types::provider::SharedCredentialsProvider; | ||
|
@@ -86,24 +85,12 @@ impl AwsAuthProps { | |
} | ||
} | ||
|
||
async fn build_credential_provider(&self) -> anyhow::Result<SharedCredentialsProvider> { | ||
if self.access_key.is_some() && self.secret_key.is_some() { | ||
Ok(SharedCredentialsProvider::new( | ||
aws_credential_types::Credentials::from_keys( | ||
self.access_key.as_ref().unwrap(), | ||
self.secret_key.as_ref().unwrap(), | ||
self.session_token.clone(), | ||
), | ||
)) | ||
} else { | ||
let region = self.build_region().await?; | ||
let mut chain = DefaultCredentialsChain::builder().region(region); | ||
|
||
if let Some(profile_name) = self.profile.as_ref() { | ||
chain = chain.profile_name(profile_name) | ||
} | ||
Ok(SharedCredentialsProvider::new(chain.build().await)) | ||
} | ||
fn build_credential_provider(&self) -> SharedCredentialsProvider { | ||
SharedCredentialsProvider::new(aws_credential_types::Credentials::from_keys( | ||
self.access_key.as_ref().unwrap_or(&"".into()), | ||
self.secret_key.as_ref().unwrap_or(&"".into()), | ||
self.session_token.clone(), | ||
)) | ||
} | ||
|
||
async fn with_role_provider( | ||
|
@@ -127,7 +114,7 @@ impl AwsAuthProps { | |
pub async fn build_config(&self) -> anyhow::Result<SdkConfig> { | ||
let region = self.build_region().await?; | ||
let credentials_provider = self | ||
.with_role_provider(self.build_credential_provider().await?) | ||
.with_role_provider(self.build_credential_provider()) | ||
.await?; | ||
let config_loader = aws_config::from_env() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should change this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the problem is about finding an alternative for
It is not recommended to build |
||
.region(region) | ||
|
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.
Should we reject it in fe?
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.
But might be ok as a quick fix
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.
still discussing with @arkbriar, whether we should continuously support public buckets.
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.
Prefer to keep it. It's up to user's choice, not our fault.