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

Automatically Disable Accounts #1532

Closed
wants to merge 18 commits into from
Closed

Automatically Disable Accounts #1532

wants to merge 18 commits into from

Conversation

bgtripp
Copy link

@bgtripp bgtripp commented Sep 20, 2022

🗣 Description

Adds the ability to disable/re-enable user accounts for global admins, and a lambda function that automatically disables accounts that have been inactive for over 60 days. Disabled accounts are able to initially authenticate via Login.gov, but will not receive an authorization token from the callback endpoint.

💭 Motivation and context

See issue #958

@bgtripp bgtripp self-assigned this Sep 20, 2022
@bgtripp bgtripp linked an issue Sep 20, 2022 that may be closed by this pull request
@bgtripp bgtripp marked this pull request as draft September 20, 2022 00:04
@lgtm-com
Copy link
Contributor

lgtm-com bot commented Sep 20, 2022

This pull request introduces 1 alert when merging 5a999ce into 48dc0dc - view on LGTM.com

new alerts:

  • 1 for Superfluous trailing arguments

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Sep 20, 2022

This pull request introduces 1 alert when merging fe62052 into 48dc0dc - view on LGTM.com

new alerts:

  • 1 for Superfluous trailing arguments

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Sep 20, 2022

This pull request introduces 1 alert when merging 4457b31 into 48dc0dc - view on LGTM.com

new alerts:

  • 1 for Superfluous trailing arguments

backend/src/tasks/autoDisableAccounts.ts Show resolved Hide resolved
backend/src/tasks/autoDisableAccounts.ts Outdated Show resolved Hide resolved
backend/src/tasks/autoDisableAccounts.ts Outdated Show resolved Hide resolved
backend/src/tasks/autoDisableAccounts.ts Outdated Show resolved Hide resolved
backend/test/auth.test.ts Outdated Show resolved Hide resolved
.send({ firstName, lastName, disabled: false })
.expect(403);
expect(response.body).toEqual({});
});
});
Copy link
Member

Choose a reason for hiding this comment

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

We should also add tests in, for example, domains.test.ts, that ensure that if a user with disabled: true accesses the domains list endpoint, it should return a 403.

Copy link
Member

Choose a reason for hiding this comment

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

@bgtripp I can't seem to find where you implemented this test though. Can you double check to see if you added it? (I believe 3a8b223 is different)

Copy link
Author

Choose a reason for hiding this comment

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

@epicfaace IIRC, this test in users.test.ts validates that users with disabled: true cannot authenticate, and 3a8b223 validates that users that have already authenticated but have since been disabled can not get authorization to hit any endpoint.

Copy link
Member

Choose a reason for hiding this comment

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

This test in users.test.ts doesn't validate that users with disabled: true cannot authenticate. It just validates that users cannot set the disabled property.

Copy link
Member

Choose a reason for hiding this comment

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

Happy to chat offline if this is unclear!

Copy link
Author

Choose a reason for hiding this comment

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

Oops, I meant the test 'verify disabled accounts cannot get tokens' in auth.test.ts validates that users with disabled: true cannot authenticate, not this one in users.test.ts.

Copy link
Member

@epicfaace epicfaace Apr 7, 2023

Choose a reason for hiding this comment

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

Yes, that's correct, though in this thread I was originally asking to see if we could add a test in domains.test.ts, that ensure that if a user with disabled: true accesses the domains list endpoint, it should return a 403. Just an end-to-end test making sure this is true -- could you please add it?

As you mentioned, the test 'verify disabled accounts cannot get tokens' in auth.test.ts validates that users with disabled: true cannot call the callback endpoint, but 3a8b223 only checks API keys. So I think adding the above test would be helpful to ensure we cover everything.

Copy link
Contributor

Choose a reason for hiding this comment

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

Once the above is done this is ready to go

frontend/src/context/AuthContextProvider.tsx Outdated Show resolved Hide resolved
frontend/src/pages/Users/Users.tsx Outdated Show resolved Hide resolved
@lgtm-com
Copy link
Contributor

lgtm-com bot commented Sep 21, 2022

This pull request introduces 1 alert when merging 2b87d71 into 48dc0dc - view on LGTM.com

new alerts:

  • 1 for Superfluous trailing arguments

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Sep 26, 2022

This pull request introduces 1 alert when merging fd25107 into 48dc0dc - view on LGTM.com

new alerts:

  • 1 for Superfluous trailing arguments

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Sep 26, 2022

This pull request introduces 1 alert when merging 3a8b223 into 48dc0dc - view on LGTM.com

new alerts:

  • 1 for Superfluous trailing arguments

@epicfaace epicfaace mentioned this pull request Jan 19, 2023
@bgtripp bgtripp marked this pull request as ready for review April 7, 2023 01:51
@epicfaace
Copy link
Member

@bgtripp Can you also re-merge the master branch with this branch so we can run CI again? Thanks!

expect(user.disabled).toEqual(true);
});
it('update by globalAdmin that enables user should work', async () => {
const response = await request(app)
Copy link
Member

Choose a reason for hiding this comment

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

I think you need to add, at the beginning of this test,

      const response = await request(app)
        .put(`/users/${user.id}`)
        .set(
          'Authorization',
          createUserToken({
            userType: UserType.GLOBAL_ADMIN
          })
        )
        .send({ firstName, lastName, disabled: true })
        .expect(200);

so that the user is disabled in the first place.

Copy link
Contributor

Choose a reason for hiding this comment

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

@epicfaace - Agreed

.send({ firstName, lastName, disabled: false })
.expect(403);
expect(response.body).toEqual({});
});
});
Copy link
Member

Choose a reason for hiding this comment

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

This test in users.test.ts doesn't validate that users with disabled: true cannot authenticate. It just validates that users cannot set the disabled property.

@epicfaace
Copy link
Member

@mbachtell-nais if you could also take a look at this PR, that would be great! This PR is by @bgtripp and involves automatically disabling accounts after a certain period of inactivity.

@schmelz21
Copy link
Collaborator

OBE

@schmelz21 schmelz21 closed this Feb 2, 2024
@schmelz21 schmelz21 added the OBE Overtaken By Events label Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OBE Overtaken By Events
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically disable / expire accounts after a period of time
4 participants