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

[Feature request] Force security if not protected #4087

Merged
merged 8 commits into from
Aug 3, 2023

Conversation

manuelplazaspalacio
Copy link
Contributor

@manuelplazaspalacio manuelplazaspalacio commented Jun 28, 2023

Related Issues

App: #4061

Library PR (if needed):

  • Added changelog files for the fixed issues in folder changelog/unreleased. More info here

QA

#4087 (comment)

manuelplazaspalacio added a commit that referenced this pull request Jun 28, 2023
@manuelplazaspalacio manuelplazaspalacio self-assigned this Jun 28, 2023
manuelplazaspalacio added a commit that referenced this pull request Jun 28, 2023
@manuelplazaspalacio manuelplazaspalacio force-pushed the feature/force_security_if_not_protected branch from 29be800 to b889f1b Compare June 28, 2023 07:05
@manuelplazaspalacio manuelplazaspalacio linked an issue Jun 28, 2023 that may be closed by this pull request
9 tasks
@manuelplazaspalacio manuelplazaspalacio force-pushed the feature/force_security_if_not_protected branch from d24fb0c to 73d6f63 Compare June 28, 2023 08:55
Copy link
Collaborator

@JuancaG05 JuancaG05 left a comment

Choose a reason for hiding this comment

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

Some changes suggested here @manuelplazaspalacio!

@manuelplazaspalacio manuelplazaspalacio force-pushed the feature/force_security_if_not_protected branch 3 times, most recently from 5cfb2c7 to 420a37b Compare July 7, 2023 12:48
Copy link
Collaborator

@JuancaG05 JuancaG05 left a comment

Choose a reason for hiding this comment

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

Last changes here 😁 good job @manuelplazaspalacio!

@@ -285,39 +286,46 @@ fun Activity.hideSoftKeyboard() {
fun Activity.checkPasscodeEnforced(securityEnforced: SecurityEnforced) {
val sharedPreferencesProvider = OCSharedPreferencesProvider(this)

// If device protection is false, launch the previous behaviour (check the lockEnforced).
// If device protection is true, check the lockEnforced only if device is not secure.
val deviceProtection: Boolean = !this.resources.getBoolean(R.bool.device_protection) || !isDeviceSecure()
Copy link
Collaborator

Choose a reason for hiding this comment

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

device_protection should be retrieved from the MDM provider since we have the option there 👍

Copy link
Collaborator

Choose a reason for hiding this comment

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

So, regarding the new methods, we are testing the method isSecurityEnforcedEnabled, so tests should always start by is security enforced enabled and not by is security enforced disabled, we are mixing here the name of the method to test with the locked enforced value.
I would propose a new naming for all these tests:
is security enforced enabled {true|false} - ok - device {not} secure {no} device protection {no} lock enforced
So that we know which method we are testing (is security enforced enabled), the expected result of this test case ({true|false}), and the value of each of the 3 parameters involved (device {not} secure {no} device protection {no} lock enforced).

@jesmrec
Copy link
Collaborator

jesmrec commented Jul 11, 2023

tested with <bool name="device_protection">true</bool> to check new behaviours.

  1. Fresh installation

lock_enforced is 0

Device protected Device not protected
App not protected Passcode not asked and enable in Settings ✅ Passcode must be asked and not removable. Behaviour like lock_enforced = 1

lock_enforced is not 0 (passcode enforced)

Device protected Device not protected
App not protected Passcode is enforced and must be asked and not allowed to remove ✅ Passcode asked and not removable following behaviour of lock_enforced
  1. Status changes (no lock_enforce)
Test Case Steps Expected Result Result Related Comment
Set device protection I 1. App not protected
2. Device not protected
3. Add protection to device
4. Open app
App does not ask to create new passcode
Set device protection II 1. App protected
2. Device not protected
3. Add protection to device
4. Open app
App does not ask to create new passcode.
Passcode is removable from Settings
Unset device protection I 1. App not protected
2. Device protected
3. Remove protection from device
4. Open app
App asks to create new passcode/pattern.
Passcode/Pattern is not removable from Settings
Unset device protection II 1. App protected
2. Device protected
3. Remove protection from device
4. Open app
App does not ask to create new passcode.
Passcode is not removable from Settings
Set app protection I 1. App not protected
2. Device not protected
3 Open app
App asks to create new passcode.
Passcode is not removable from Settings
Set app protection II 1. App not protected
2. Device protected
3. Add protection to app
4. Open app
App does not ask to create new passcode.
Passcode is removable from Settings
Unset app protection I 1. App protected
2. Device protected
3. Remove protection from app
4. Open app
App does not ask to create new passcode
Unset app protection II 1. App protected
2. Device not protected
3. Remove protection from app
Passcode is not removable from Settings

Summarizing:

  • lock_enforced prevails over device_protection

  • If lock is enforced (!=0), the protection condition is always fulfilled (app protected || device protected || both protected) and the value of device_protection does not matter.

  • If lock is not enforced (==0), we have to assure always that the protection condition is fulfilled if device_protection is true.

@jesmrec
Copy link
Collaborator

jesmrec commented Jul 11, 2023

(1) [FIXED]

I was not able to reproduce the base case

  1. Remove all the security methods in device, so screen is never locked and content is accesible without entering pin, fingerprint, face and so on
  2. Set device_protection to true
  3. Install the app from scratch

Current: Security method is not asked after first open, user can enter URL and work with the app without security in app and device

Expected: device_protection as true should not allow users to use the app without app security methods.

Pixel2 Android11
c8261845d

@manuelplazaspalacio manuelplazaspalacio force-pushed the feature/force_security_if_not_protected branch from c826184 to 7805174 Compare August 1, 2023 08:17
Copy link
Contributor

@jabarros jabarros left a comment

Choose a reason for hiding this comment

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

LGTM

@jesmrec
Copy link
Collaborator

jesmrec commented Aug 2, 2023

(2) [FIXED]

Set

<bool name="device_protection">true</bool>
<integer name="lock_enforced">3</integer>

then, install the app from scratch

Current: app is asking users to choose pattern or passcode
Expected: lock_enforced is 3, so pattern is enforced. Pattern enabled prevails.

Pixel 2 Android 11
c65e7f8

manuelplazaspalacio and others added 8 commits August 3, 2023 10:31
Adding device to security checks.
Modifying and adding tests for new security checks.
Adding comments to devices protection checks.
Changing device protection messages.
Obtaining the device protection from the MdmProvider.
@manuelplazaspalacio manuelplazaspalacio force-pushed the feature/force_security_if_not_protected branch from 0a936e8 to bad94b8 Compare August 3, 2023 08:32
@jesmrec
Copy link
Collaborator

jesmrec commented Aug 3, 2023

Approved. Ready to go

@manuelplazaspalacio manuelplazaspalacio merged commit f585ec4 into master Aug 3, 2023
5 checks passed
@manuelplazaspalacio manuelplazaspalacio deleted the feature/force_security_if_not_protected branch August 3, 2023 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] Force security if device is not protected
4 participants