~roadmr/canonical-identity-provider:2fa-update-last-nag-paper-only

Last commit made on 2020-06-18
Get this branch:
git clone -b 2fa-update-last-nag-paper-only https://git.launchpad.net/~roadmr/canonical-identity-provider
Only Daniel Manrique can upload to this branch. If you are Daniel Manrique please log in for upload directions.

Branch merges

Branch information

Name:
2fa-update-last-nag-paper-only
Repository:
lp:~roadmr/canonical-identity-provider

Recent commits

10fc368... by Daniel Manrique

Update last_nag only for codes from paper device

63a1d62... by Daniel Manrique

Add test to ensure last_nag is only updated when using a paper device code

bec95af... by Daniel Manrique

make_device() makes horrible, empty, useless devices

d6e4a38... by Daniel Manrique

Revert this which doesn't work :(

It broke on staging with "selective" switch using condition json payload.

Need to add tests for it, reverting in the meanwhile.

Merged from https://code.launchpad.net/~roadmr/canonical-identity-provider/+git/canonical-identity-provider/+merge/386016

f7c62a9... by Daniel Manrique

Revert "Update gargoyle-yplan to 1.5.0"

This reverts commit d8bff9ed50ca966e5631eb96abadcc1acb71e163.

Note this reverts only the actual requirements.txt updates, not the
fixed test (since the fixed version still works and should be more
robust)

51120a6... by Daniel Manrique

Update gargoyle-yplan to 1.5.0

Also declare and pin gargoyle-yplan deps

The gargoyle we are using is ancient and incompatible with Django 1.11
management commands (add_switch is especially useful).

Merged from https://code.launchpad.net/~roadmr/canonical-identity-provider/+git/canonical-identity-provider/+merge/385955

a5d6754... by Daniel Manrique

Fix assertable value scoping

eef7fff... by Daniel Manrique

fix test that failed with upgraded django-modeldict.

django-modeldict-yplan calls time.time() to get a timestamp to store
modeldict data in Django cache. Prior to 1.5.3 it would int(time.time())
but as of 1.5.3 it stopped doing that and uses time.time() directly.

mocky = mock.MagicMock()
int(mocky) # this is 1, it will be relevant soon.

A bug had been lurking in test_saml_time_conditions since times
immemorial: it was using @patch as a decorator to mock time.time in a
saml2idp (saml2idp.base.time.time), but since it was running time.time()
inside the test method to set up the mock's return value, this resulted
in an inadvertent circular mock:

@patch('saml2idp.base.time.time')
...
  now = time.time() # You think this is the system time.time but it's
                     # actually your mock at this point
  mock_time.return_value = now # You're making your mock method
                                # return a mock

For some reason, the time.time mocking in saml2idp.base was bleeding
into django-modeldict's update_cache_data method, and since we updated
to version 2.0.3, the rounding behavior explained above which was hiding
the fact that we're passing around a mock instead of a time value
disappeared, exposing a bug where trying to pickle the mocky time in
order to store it in django cache (memcached, here) resulted in

PicklingError: Can't pickle <class 'mock.MagicMock'>: it's not the same object as mock.MagicMock

As seen in the code, the fix was to rearrange scoping so we obtain the
value of time.time() we will set as the mock's return_value *outside* of
the mock's scope.

d8bff9e... by Daniel Manrique

Update gargoyle-yplan to 1.5.0

Also declare and pin gargoyle-yplan deps

The gargoyle we are using is ancient and incompatible with Django 1.11
management commands (add_switch is especially useful).

bf88c99... by Daniel Manrique

Periodically nag 2FA users to enter a code from their backup device instead of the primary.

To be clear, a code from the primary or any other device is still accepted.

This is a "soft/gentle" approach to getting people to test their backup device every once in a while *before* they get locked out.

Every X days, a nag message is shown on top of the usual 2FA screen informing users they can enter a backup code and how it helps ensure they are still valid. It also shows the most recent use date for *any* backup device.

The TWOFACTOR_BACKUP_NAG flag controls this behavior, and time between nags is controlled by the "TWOFACTOR_BACKUP_NAG_INTERVAL setting which has a value of 42 days but can be changed.

Merged from https://code.launchpad.net/~roadmr/canonical-identity-provider/+git/canonical-identity-provider/+merge/385834