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
custom: | |
appSync: | |
name : ${self:provider.apiname} | |
region : ${self:provider.region} | |
authenticationType : AWS_IAM | |
serviceRole : "AppSyncServiceRole" |
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
#======================================================================================= | |
IdentityPool: | |
Type : AWS::Cognito::IdentityPool | |
Description : "Federation for the User Pool members to access AWS resources" | |
Properties: | |
IdentityPoolName : ${self:provider.apiname}_identities | |
AllowUnauthenticatedIdentities : true | |
CognitoIdentityProviders: | |
- ClientId : { Ref: AndroidUserPoolClient } | |
ProviderName : { Fn::Sub: [ 'cognito-idp.${self:provider.region}.amazonaws.com/#{client}', { "client": { Ref: CognitoUserPoolMyPool }}]} |
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
#======================================================================================= | |
AuthRole: | |
Type : AWS::IAM::Role | |
Description : "Role that the an authenticated user assumes" | |
Properties: | |
RoleName : ${self:provider.apiname}-auth | |
AssumeRolePolicyDocument: | |
Version : "2012-10-17" | |
Statement: | |
- Effect : Allow |
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
#======================================================================================= | |
CognitoUserPoolMyPool: | |
Type : AWS::Cognito::UserPool | |
Description : "Username / Password auth database" | |
Properties: | |
UserPoolName : ${self:provider.apiname} | |
Schema: | |
- Name : email | |
Required : true | |
Mutable : true |
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
/** | |
* Load the data from the biometric store and populate the right fields | |
*/ | |
private fun loadFromBiometricStore() { | |
if (whorlwind?.canStoreSecurely() == true) { | |
val disposable = whorlwind!!.read("password") | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe { result -> | |
when (result.readState) { |
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
/** | |
* Save the current form data to the biometric store | |
*/ | |
private fun saveToBiometricStore(password: String) { | |
if (whorlwind?.canStoreSecurely() == true) { | |
val disposable = Observable.just(password) | |
.observeOn(Schedulers.io()) | |
.flatMapCompletable {value -> | |
whorlwind?.write("password", ByteString.encodeUtf8(value)) | |
} |
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
IdentityRequest.SUCCESS -> { | |
analyticsService.recordSuccessfulLogin(loginFormUsernameField.text.toString()) | |
model.updateStoredUsername(loginFormUsernameField.text.toString()) | |
saveToBiometricStore(loginFormPasswordField.text.toString()) | |
[email protected]() | |
} |
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
/** | |
* Callback for when the permissions has been requested and responded to. | |
*/ | |
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) { | |
when (requestCode) { | |
REQUEST_PERMISSIONS_FINGERPRINT -> { | |
checkedPermissions = true | |
hasPermissions = (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) | |
} |
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
// Ask for permission to use the fingerprint scanner | |
if (fingerprintManager.isHardwareDetected) { | |
if (checkSelfPermission(Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { | |
if (checkedPermissions) { | |
hasPermissions = false | |
} else { | |
requestPermissions(arrayOf(Manifest.permission.USE_FINGERPRINT), REQUEST_PERMISSIONS_FINGERPRINT) | |
} | |
} else { | |
hasPermissions = true |
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
class AuthenticatorActivity : AppCompatActivity() { | |
companion object { | |
private const val REQUEST_PERMISSIONS_FINGERPRINT = 90001 | |
} | |
private val model by viewModel<AuthenticatorViewModel>() | |
private val analyticsService by inject<AnalyticsService>() | |
// For permissions checks | |
private var checkedPermissions = false |