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

Remove inactive users #305

Merged
merged 17 commits into from Aug 3, 2022
Merged

Conversation

pjcon
Copy link
Contributor

@pjcon pjcon commented Sep 20, 2021

Users who have a lastLoginDate from more than 18 months ago will be removed.

Also catch the case where users who have not logged in since the addition of lastLoginDate, which means they don't have a lastLoginDate. They are also removed.

Depends on #171 is now merged into dev
Merge after #284

@pjcon pjcon requested a review from a team as a code owner September 20, 2021 13:52
@gregcorbett gregcorbett self-assigned this Sep 20, 2021
@gregcorbett gregcorbett added this to the 5.10.0 milestone Sep 20, 2021
@pjcon pjcon force-pushed the cjp/remove-inactive-users branch 3 times, most recently from 3a723da to 67d74eb Compare October 6, 2021 13:25
@gregcorbett
Copy link
Member

some of the commits can be squashed, as they seem to comment-out and un-comment-out bits of code.

@gregcorbett gregcorbett requested a review from a team October 18, 2021 10:01
@pjcon
Copy link
Contributor Author

pjcon commented Oct 18, 2021

some of the commits can be squashed, as they seem to comment-out and un-comment-out bits of code.

How far should I go to squash commits? I've mixed in some commits together while working, and I figure it'd be faff to pick them apart.

@pjcon pjcon force-pushed the cjp/remove-inactive-users branch 3 times, most recently from 87626a0 to b8f2c46 Compare October 18, 2021 16:03
@gregcorbett
Copy link
Member

How far should I go to squash commits? I've mixed in some commits together while working, and I figure it'd be faff to pick them apart.

You can probably go quite far with the squashing, along the lines of:

  1. Basic Script
  2. Add functionality to email users
  3. handle really old users without a last login

@pjcon pjcon force-pushed the cjp/remove-inactive-users branch 3 times, most recently from 725b3c9 to cc6a597 Compare October 28, 2021 11:13
@gregcorbett
Copy link
Member

I've rebased this on top of the current dev so I can see how it works with ID linking.

@gregcorbett gregcorbett force-pushed the cjp/remove-inactive-users branch 3 times, most recently from aca0540 to 7f325d9 Compare May 27, 2022 13:49
@ineilson
Copy link
Contributor

#284 doesn't provided a means of cleaning up old/inactive API authentication credentials does it? Maybe in the short term we refuse to delete a user with an API authentication credential.

No, it forces the reassignment/deletion of the API credential before the user can be removed.

Short term: that sounds good given the limited API cred usage, but there should be some monitoring/log of failures from the automated script to allow follow-up.

@gregcorbett
Copy link
Member

As a note to future Greg,

if (!$user->getAPIAuthenticationEntities()->isEmpty()) {

should be factored out into a method that the runner makes use of.

ineilson
ineilson previously approved these changes Jul 11, 2022
@gregcorbett
Copy link
Member

Need to rebase this to pick up the changes from #284.

pjcon and others added 15 commits July 29, 2022 14:58
- GOCDB admins email is better because it doesn't matter what
  view the user uses.
- it's also consistent with other mails sent (e.g. role requests,
  ID linking).
- to be more consistent with itself and other emails sent
- for consistency and PSR-12 compliance
- as the time this script starts is already captured above.
- we don't want to return here (and skip the rest of the users),
  we want to continue on to the next user.
- As this script is stateless and might be run weekly, hence
  a used will get ~4 warnings and we don't want each one saying
  "30 days".
Co-authored-by: ineilson <ian.neilson@stfc.ac.uk>
- so that they can be changed in production based on how
  frequently the script runs.
- to prevent deleting the user and creating orphaned API
  credentials.
@gregcorbett
Copy link
Member

There is now (#284

if (!$user->getAPIAuthenticationEntities()->isEmpty()) {

@ineilson: I've address the above now - in a97fc22

@tofu-rocketry: Following our discussions about how frequently this should run / how much warning a user should have get, I've softcoded thresholds for warning and deletion - in e86f594

Copy link
Contributor

@ineilson ineilson left a comment

Choose a reason for hiding this comment

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

Looks okay. If a deletion fails for any user for some reason the whole thing stops. That's intended behaviour?

@gregcorbett
Copy link
Member

Looks okay. If a deletion fails for any user for some reason the whole thing stops. That's intended behaviour?

maybe "intended" is to strong a word, but it feels like an okay thing to do.

@gregcorbett gregcorbett merged commit 593b79d into GOCDB:dev Aug 3, 2022
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.

None yet

4 participants