-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
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
# Conflicts: # README.md
ALS-1862 Authentication with API key added
README.md
Outdated
// Create a credentail provider using Identity Pool Id with AuthHelper | ||
private fun exampleCognitoLogin() { | ||
private suspend fun exampleCognitoLogin() { |
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.
Nit: "credentail" -> "credential"
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.
Fixed
README.md
Outdated
// Create a credentail provider using custom credential provider with AuthHelper | ||
private fun exampleCustomCredentialLogin() { | ||
private suspend fun exampleCustomCredentialLogin() { |
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.
"credential"
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.
Fixed
README.md
Outdated
|
||
OR | ||
|
||
// Create a credentail provider using Api key with AuthHelper |
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.
"credential"
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.
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() |
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 this be locationCredentialsProvider?.getLocationClient()
?
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.
Fixed
credentials | ||
) | ||
val credentials = cognitoIdentityClient?.getCredentialsForIdentity(GetCredentialsForIdentityRequest { this.identityId = identityId }) | ||
?.credentials ?: throw Exception("Failed to get credentials") |
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.
Nit: "Failed to get credentials" (one space between 'get' and 'credentials')
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.
Fixed
if ((method == "custom" || method == "apiKey") && customCredentials != null) { | ||
return customCredentials |
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 this return empty credentials instead of customCredentials for apiKey?
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.
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( |
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.
Why did internal get removed off of these?
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.
I thought it would be helpful for our users to access that method but reverted back due to security concerns.
const val HASHING_ALGORITHM = "SHA-256" | ||
const val MAC_ALGORITHM = "HmacSHA256" | ||
const val ENCODED_CHARACTER_REGEX = "%[0-9A-Fa-f]{2}" |
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.
Why did internal get removed from this file too?
fix: Api key get credential returns empty credential fix fix: CryptoUtils.kt and AwsAuthorizationHeaderHelper.kt files method revert back to internal ALS-1862
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
andAwsAuthorizationHeaderHelper.kt
functions changed to open from internalBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.