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

Android Fingerprint #195

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e988f29
Added fingerprintManager for Android biometry support
cladjules Jul 17, 2018
46ce672
added algo iv for decrypt
cladjules Jul 17, 2018
bac96c7
Cleanup
cladjules Jul 18, 2018
c67692f
added separate CipherStorageKeystoreRSAECB for biometry only
cladjules Sep 9, 2018
27a463e
cancel fingerprintCancellation when auth fails
cladjules Sep 9, 2018
2e530de
rn keychain compat bio
cladjules Oct 21, 2018
14f9139
refactor androidx biometric into app compat v4
Nov 20, 2018
3052876
fixed issue and import
Nov 20, 2018
fa8b7ad
added check for fingerprint and set proper permissiosn
cladjules Nov 21, 2018
2c86afe
cleanup with commits from PR
cladjules Nov 21, 2018
a11691c
typo fix
cladjules Nov 21, 2018
795a487
edit with pr
Nov 22, 2018
8d5db02
cleanup and added commits from the PR
cladjules Nov 22, 2018
315881d
detect biometry cipher storage when removing old data
Nov 23, 2018
fa2a294
set proper ios method definition
Nov 23, 2018
3c44296
check if cipherStorage has changed and update ios project
cladjules Nov 24, 2018
b1c97fa
cleanup import and set setText in a UI Handler
Nov 26, 2018
fa57fc0
set exceptino to InvalidKeyException
Nov 27, 2018
943333d
fixed issue with android < 5.0
Nov 27, 2018
e18fe20
Added check for android < M and getting biometry cipher
Nov 27, 2018
8886c35
Removed exception thrown when authFailed and check fragment already a…
Jan 22, 2019
632dd85
added nullPointerException
Jan 29, 2019
bce5332
use fragment manager rather than support
cladjules Apr 17, 2019
17ccc09
fixed some issues attaching fragments and added local strings
cladjules May 4, 2019
0fa159c
Merge branch 'master' into androidFragment
cladjules May 4, 2019
24f83cc
solved comments and cleanup
cladjules Jun 17, 2019
c87bfc1
Merge branch 'master' into master
cladjules Jul 1, 2019
f4c1b81
Refactor and use cipherStorage Base class
cladjules Jul 13, 2019
c648d1b
added getAccessControl function and use String across
cladjules Jul 17, 2019
af9254a
Refactor SecretKey to use KeyPair in RSA
cladjules Jul 27, 2019
8ccf178
improve stability and check some nullable
Sep 10, 2019
b77c278
Refactor using androidX Library
cladjules Oct 19, 2019
5752483
cleanup imports
cladjules Oct 19, 2019
3e985e2
cleanup code and variables
cladjules Oct 19, 2019
a88b962
Merge https://github.com/oblador/react-native-keychain
cladjules Oct 19, 2019
dce043c
add activity to cipherStorage
cladjules Jan 11, 2020
1507676
Merge branch 'master' of https://github.com/oblador/react-native-keyc…
cladjules Jan 11, 2020
4beddc6
merge with master and added methods
cladjules Jan 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
logs
*.log

#Android
android/.gradle/
android/.idea/
android/android.iml
android/local.properties
android/react-native-keychain.iml

# Runtime data
pids
*.pid
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![Travis](https://img.shields.io/travis/oblador/react-native-keychain.svg)](https://travis-ci.org/oblador/react-native-keychain) [![npm](https://img.shields.io/npm/v/react-native-keychain.svg)](https://npmjs.com/package/react-native-keychain) [![npm](https://img.shields.io/npm/dm/react-native-keychain.svg)](https://npmjs.com/package/react-native-keychain)

Keychain/Keystore Access for React Native.
Keychain/Keystore Access for React Native.

## Installation

Expand Down Expand Up @@ -89,9 +89,9 @@ Inquire if the type of local authentication policy is supported on this device w

Get what type of hardware biometry support the device has. Resolves to a `Keychain.BIOMETRY_TYPE` value when supported, otherwise `null`.

### `getSecurityLevel()` (Android only)
### `getSecurityLevel({ accessControl })` (Android only)

Get security level that is supported on the current device with the current OS.
Get security level that is supported on the current device with the current OS for the `accessControl` option.

### Security Levels (Android only)

Expand All @@ -105,11 +105,11 @@ If set, `securityLevel` parameter specifies minimum security level that the encr

| Key | Platform | Description | Default |
|---|---|---|---|
|**`accessControl`**|iOS only|This dictates how a keychain item may be used, see possible values in `Keychain.ACCESS_CONTROL`. |*None*|
|**`accessControl`**|All|This dictates how a keychain item may be used, see possible values in `Keychain.ACCESS_CONTROL`. |*None*|
|**`accessible`**|iOS only|This dictates when a keychain item is accessible, see possible values in `Keychain.ACCESSIBLE`. |*`Keychain.ACCESSIBLE.WHEN_UNLOCKED`*|
|**`accessGroup`**|iOS only|In which App Group to share the keychain. Requires additional setup with entitlements. |*None*|
|**`authenticationPrompt`**|iOS only|What to prompt the user when unlocking the keychain with biometry or device password. |`Authenticate to retrieve secret`|
|**`authenticationType`**|iOS only|Policies specifying which forms of authentication are acceptable. |`Keychain.AUTHENTICATION_TYPE.DEVICE_PASSCODE_OR_BIOMETRICS`|
|**`authenticationType`**|All|Policies specifying which forms of authentication are acceptable. |`Keychain.AUTHENTICATION_TYPE.DEVICE_PASSCODE_OR_BIOMETRICS`|
|**`service`**|All|Reverse domain name qualifier for the service associated with password. |*App bundle ID*|

#### `Keychain.ACCESS_CONTROL` enum
Expand Down Expand Up @@ -198,7 +198,7 @@ include ':app'
+ project(':react-native-keychain').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keychain/android')
```

* Edit `android/app/build.gradle` (note: **app** folder) to look like this:
* Edit `android/app/build.gradle` (note: **app** folder) to look like this:

```diff
apply plugin: 'com.android.application'
Expand Down Expand Up @@ -236,7 +236,7 @@ public class MainActivity extends extends ReactActivity {
...
}
```

#### Proguard Rules

On Android builds that use proguard (like release), you may see the following error:
Expand All @@ -256,7 +256,7 @@ If so, add a proguard rule in `proguard-rules.pro`:

## Notes

### Android
### Android

The module will automatically use the appropriate CipherStorage implementation based on API level:

Expand Down
4 changes: 2 additions & 2 deletions RNKeychainManager/RNKeychainManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ - (OSStatus)deleteCredentialsForServer:(NSString *)server
}
#endif

RCT_EXPORT_METHOD(setGenericPasswordForOptions:(NSDictionary *)options withUsername:(NSString *)username withPassword:(NSString *)password withSecurityLevel:(__unused NSString *)level resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(setGenericPasswordForOptions:(NSDictionary *)options withUsername:(NSString *)username withPassword:(NSString *)password withSecurityLevel:(__unused NSString *)level withAccessControl:(__unused NSString *)accessControl resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
{
NSString *service = serviceValue(options);
NSDictionary *attributes = attributes = @{
Expand Down Expand Up @@ -359,7 +359,7 @@ - (OSStatus)deleteCredentialsForServer:(NSString *)server
return resolve(@(YES));
}

RCT_EXPORT_METHOD(setInternetCredentialsForServer:(NSString *)server withUsername:(NSString*)username withPassword:(NSString*)password withSecurityLevel:(__unused NSString *)level withOptions:(NSDictionary *)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(setInternetCredentialsForServer:(NSString *)server withUsername:(NSString*)username withPassword:(NSString*)password withSecurityLevel:(__unused NSString *)level withAccessControl:(__unused NSString *)accessControl withOptions:(NSDictionary *)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
{
[self deleteCredentialsForServer:server];

Expand Down
23 changes: 17 additions & 6 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
buildscript {
repositories {
jcenter()
maven {
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can just use google(), and ideally put it to the top

url 'https://maven.google.com/'
name 'Google'
}
}

dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
classpath 'com.android.tools.build:gradle:3.2.1'
}
}

Expand All @@ -15,12 +19,12 @@ def safeExtGet(prop, fallback) {
}

android {
compileSdkVersion safeExtGet('compileSdkVersion', 28)
buildToolsVersion safeExtGet('buildToolsVersion', '26.0.3')
compileSdkVersion safeExtGet('compileSdkVersion', 28)
buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')

defaultConfig {
targetSdkVersion safeExtGet('targetSdkVersion', 28)
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 26)
versionCode 1
versionName "1.0"
}
Expand All @@ -31,9 +35,16 @@ android {

repositories {
mavenCentral()
maven {
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can just use google()

url 'https://maven.google.com/'
name 'Google'
}
}

dependencies {
implementation 'com.facebook.react:react-native:+'
implementation 'com.facebook.conceal:conceal:1.1.3@aar'
implementation 'com.android.support:support-v4:27.0.2'
Copy link
Contributor

Choose a reason for hiding this comment

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

we should align to version 28.0.0 - it guaranty that androidx with jetifier tool will be without any problems.

implementation 'com.facebook.react:react-native:+'
implementation 'com.facebook.conceal:conceal:1.1.3@aar'
implementation 'android.arch.lifecycle:runtime:1.1.0'
annotationProcessor 'android.arch.lifecycle:compiler:1.1.0'
}
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Oct 21 11:34:03 PDT 2015
#Sun Oct 21 15:04:55 BST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
Copy link
Contributor

Choose a reason for hiding this comment

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

5.6.2 is the latest

4 changes: 3 additions & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.oblador.keychain">
<uses-permission android:name="android.permission.USE_FINGERPRINT" />

<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
</manifest>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.oblador.keychain;

import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Build;
import android.content.Context;
import android.app.KeyguardManager;
Expand All @@ -10,7 +12,9 @@ public static boolean isFingerprintAuthAvailable(Context context) {
if (android.os.Build.VERSION.SDK_INT >= 23) {
FingerprintManager fingerprintManager =
(FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
return fingerprintManager != null && fingerprintManager.isHardwareDetected() &&
return fingerprintManager != null &&
context.checkSelfPermission(Manifest.permission.USE_FINGERPRINT) == PackageManager.PERMISSION_GRANTED &&
fingerprintManager.isHardwareDetected() &&
fingerprintManager.hasEnrolledFingerprints();
}
return false;
Expand Down
Loading