Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

SCIM: Add support for soft delete#50533

Merged
chwarwick merged 13 commits into
mainfrom
cw/scim-add-soft-delete
Apr 13, 2023
Merged

SCIM: Add support for soft delete#50533
chwarwick merged 13 commits into
mainfrom
cw/scim-add-soft-delete

Conversation

@chwarwick

@chwarwick chwarwick commented Apr 11, 2023

Copy link
Copy Markdown
Contributor

When modifying users using PUT/PATCH via SCIM toggling the active property should have the effect of soft deleting and restoring the user.

This code first updates the SCIM logic to remove any user specific entity logic from the generic logic that would apply to any scim entity such as how to manipulate attributes. The effect of this is that each possible type of change is separated, and runs a check on the attributes before/after the changes to determine if it has occurred and an action needs to be taken. After this change I replaced the existing hard delete code for active changes with a soft delete/reactivate.

closes https://github.com/sourcegraph/sourcegraph/issues/49961

Test plan

image

Manual Test

SCIM POST (create user)
Set password
Sign in

SCIM GET
Verify user is listed and active

SCIM PATCH - active -> false
Verify user can not login

SCIM GET
Verify user listed with active = false

SCIM PATCH - active -> true
Verify User can login again (only using username)

@cla-bot cla-bot Bot added the cla-signed label Apr 11, 2023
@sourcegraph-bot

sourcegraph-bot commented Apr 11, 2023

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff 64b9248...fa344a0.

Notify File(s)
@sourcegraph/delivery doc/admin/scim.md

@chwarwick

Copy link
Copy Markdown
Contributor Author

Sorry for the big change, there are really 2 main commits:

This commit contains all moving of files and separating user specific logic from the dealing with SCIM attributes logic. I wanted to do this because if/when we add group support we would need to do it and because manipulating the attributes code is already confusing enough that mixing in entity specific things is difficult.

This commit contains the logic changes for the soft delete.

Comment thread internal/database/users.go
Comment thread enterprise/internal/scim/resourceHandler.go
@chwarwick chwarwick requested a review from vdavid April 11, 2023 14:26
Comment thread CHANGELOG.md Outdated
Comment thread internal/database/users.go
Comment thread enterprise/internal/scim/user_service.go
Comment thread doc/admin/scim.md Outdated

@vdavid vdavid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've gone through it!
Wow, the first commit was a thick one!
I'm not saying that I went through that commit line by line, but I'm trusting you and our test coverage that it's fine.
I think your cleanup will make us very grateful to ourselves one day when we add group sync support! I didn't even realize that user-related logic was so coupled with general SCIM stuff, and the new architecture is great!
I agree that applySCIMUpdates is not ideal, but I have no better take on it now.
Overall, awesome work! Please ping me when you looked into my suggestions, and I'll do another quick review round!

@chwarwick

Copy link
Copy Markdown
Contributor Author

I've gone through it! Wow, the first commit was a thick one! I'm not saying that I went through that commit line by line, but I'm trusting you and our test coverage that it's fine. I think your cleanup will make us very grateful to ourselves one day when we add group sync support! I didn't even realize that user-related logic was so coupled with general SCIM stuff, and the new architecture is great! I agree that applySCIMUpdates is not ideal, but I have no better take on it now. Overall, awesome work! Please ping me when you looked into my suggestions, and I'll do another quick review round!

Yeah the first one is a bit much 😞 but >80% of it is just moving code not changing it at least that is what I tell myself to feel better about it.

@vdavid vdavid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yay!

@chwarwick chwarwick merged commit 7fede84 into main Apr 13, 2023
@chwarwick chwarwick deleted the cw/scim-add-soft-delete branch April 13, 2023 14:56
almeidapaulooliveira pushed a commit that referenced this pull request Apr 13, 2023
When modifying users using PUT/PATCH via SCIM toggling the `active`
property should have the effect of soft deleting and restoring the user.

This code first updates the SCIM logic to remove any user specific
entity logic from the generic logic that would apply to any scim entity
such as how to manipulate attributes. The effect of this is that each
possible type of change is separated, and runs a check on the attributes
before/after the changes to determine if it has occurred and an action
needs to be taken. After this change I replaced the existing hard delete
code for `active` changes with a soft delete/reactivate.
cesrjimenez pushed a commit that referenced this pull request Apr 14, 2023
When modifying users using PUT/PATCH via SCIM toggling the `active`
property should have the effect of soft deleting and restoring the user.

This code first updates the SCIM logic to remove any user specific
entity logic from the generic logic that would apply to any scim entity
such as how to manipulate attributes. The effect of this is that each
possible type of change is separated, and runs a check on the attributes
before/after the changes to determine if it has occurred and an action
needs to be taken. After this change I replaced the existing hard delete
code for `active` changes with a soft delete/reactivate.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SCIM: Add soft deletion feature

3 participants