Skip to content
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

Added authentication with API key and log added for generating credential failure #11

Merged
merged 6 commits into from
Sep 24, 2024

Conversation

shah279
Copy link

@shah279 shah279 commented Sep 19, 2024

Issue #, if available:

Description of changes:
feat: authentication with API key added
feat: unit test cases added for API key auth
fix: Log added for generating credentials failure
refactor: CryptoUtils.kt and AwsAuthorizationHeaderHelper.kt functions changed to open from internal

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

shah272728 and others added 4 commits September 19, 2024 16:03
feat: unit test cases added for API key auth
fix: Log added for generating credentials failure
refactor: CryptoUtils.kt and AwsAuthorizationHeaderHelper.kt functions changed to open from internal

ALS-1862
ALS-1862 Authentication with API key added
README.md Outdated
Comment on lines 37 to 38
// Create a credentail provider using Identity Pool Id with AuthHelper
private fun exampleCognitoLogin() {
private suspend fun exampleCognitoLogin() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: "credentail" -> "credential"

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

README.md Outdated
Comment on lines 46 to 47
// Create a credentail provider using custom credential provider with AuthHelper
private fun exampleCustomCredentialLogin() {
private suspend fun exampleCustomCredentialLogin() {
Copy link
Contributor

Choose a reason for hiding this comment

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

"credential"

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

README.md Outdated

OR

// Create a credentail provider using Api key with AuthHelper
Copy link
Contributor

Choose a reason for hiding this comment

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

"credential"

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

README.md Outdated
private suspend fun exampleApiKeyLogin() {
var authHelper = AuthHelper(applicationContext)
var locationCredentialsProvider : LocationCredentialsProvider = authHelper.authenticateWithApiKey("MY-API-KEY", "MY-AWS-REGION")
var locationClient = locationCredentialsProvider.getLocationClient()
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be locationCredentialsProvider?.getLocationClient()?

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

credentials
)
val credentials = cognitoIdentityClient?.getCredentialsForIdentity(GetCredentialsForIdentityRequest { this.identityId = identityId })
?.credentials ?: throw Exception("Failed to get credentials")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: "Failed to get credentials" (one space between 'get' and 'credentials')

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 360 to 361
if ((method == "custom" || method == "apiKey") && customCredentials != null) {
return customCredentials
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this return empty credentials instead of customCredentials for apiKey?

Copy link
Author

Choose a reason for hiding this comment

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

Fixed, code updated

@@ -10,7 +10,7 @@ import software.amazon.location.auth.utils.Constants.SIGNING_ALGORITHM
/**
* Sign the request with the aws authorization header
*/
internal fun Request.awsAuthorizationHeader(
fun Request.awsAuthorizationHeader(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did internal get removed off of these?

Copy link
Author

Choose a reason for hiding this comment

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

I thought it would be helpful for our users to access that method but reverted back due to security concerns.

Comment on lines 12 to 14
const val HASHING_ALGORITHM = "SHA-256"
const val MAC_ALGORITHM = "HmacSHA256"
const val ENCODED_CHARACTER_REGEX = "%[0-9A-Fa-f]{2}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did internal get removed from this file too?

shah272728 and others added 2 commits September 20, 2024 16:28
fix: Api key get credential returns empty credential fix
fix: CryptoUtils.kt and AwsAuthorizationHeaderHelper.kt files method revert back to internal

ALS-1862
@mbalfour-amzn mbalfour-amzn merged commit 608a286 into aws-geospatial:main Sep 24, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants