Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
80b2b166
Commit
80b2b166
authored
1 year ago
by
juanf
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-13940: Prevent deletions of role asignments and groups not created by system
parent
bca8fe63
No related branches found
No related tags found
1 merge request
!40
SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server-application-server/source/java/ch/systemsx/cisd/openbis/generic/server/task/UserManager.java
+16
-5
16 additions, 5 deletions
...ystemsx/cisd/openbis/generic/server/task/UserManager.java
with
16 additions
and
5 deletions
server-application-server/source/java/ch/systemsx/cisd/openbis/generic/server/task/UserManager.java
+
16
−
5
View file @
80b2b166
...
@@ -310,6 +310,7 @@ public class UserManager
...
@@ -310,6 +310,7 @@ public class UserManager
searchCriteria
.
withCodes
().
setFieldValue
(
adminGroupsByGroupId
.
keySet
());
searchCriteria
.
withCodes
().
setFieldValue
(
adminGroupsByGroupId
.
keySet
());
AuthorizationGroupFetchOptions
fetchOptions
=
new
AuthorizationGroupFetchOptions
();
AuthorizationGroupFetchOptions
fetchOptions
=
new
AuthorizationGroupFetchOptions
();
fetchOptions
.
withUsers
();
fetchOptions
.
withUsers
();
fetchOptions
.
withRegistrator
();
List
<
AuthorizationGroup
>
groups
=
service
.
searchAuthorizationGroups
(
sessionToken
,
searchCriteria
,
List
<
AuthorizationGroup
>
groups
=
service
.
searchAuthorizationGroups
(
sessionToken
,
searchCriteria
,
fetchOptions
).
getObjects
();
fetchOptions
).
getObjects
();
List
<
AuthorizationGroup
>
removedGroups
=
new
ArrayList
<>();
List
<
AuthorizationGroup
>
removedGroups
=
new
ArrayList
<>();
...
@@ -321,7 +322,10 @@ public class UserManager
...
@@ -321,7 +322,10 @@ public class UserManager
Set
<
String
>
users
=
extractUserIds
(
group
);
Set
<
String
>
users
=
extractUserIds
(
group
);
if
(
users
.
containsAll
(
extractUserIds
(
adminGroup
)))
if
(
users
.
containsAll
(
extractUserIds
(
adminGroup
)))
{
{
removedGroups
.
add
(
group
);
if
(
group
.
getRegistrator
().
getUserId
().
equals
(
"system"
))
{
removedGroups
.
add
(
group
);
}
}
}
}
}
}
}
...
@@ -334,6 +338,7 @@ public class UserManager
...
@@ -334,6 +338,7 @@ public class UserManager
searchCriteria
.
withCode
().
thatEndsWith
(
ADMIN_POSTFIX
);
searchCriteria
.
withCode
().
thatEndsWith
(
ADMIN_POSTFIX
);
AuthorizationGroupFetchOptions
fetchOptions
=
new
AuthorizationGroupFetchOptions
();
AuthorizationGroupFetchOptions
fetchOptions
=
new
AuthorizationGroupFetchOptions
();
fetchOptions
.
withUsers
();
fetchOptions
.
withUsers
();
fetchOptions
.
withRegistrator
();
List
<
AuthorizationGroup
>
adminGroups
=
service
.
searchAuthorizationGroups
(
sessionToken
,
searchCriteria
,
List
<
AuthorizationGroup
>
adminGroups
=
service
.
searchAuthorizationGroups
(
sessionToken
,
searchCriteria
,
fetchOptions
).
getObjects
();
fetchOptions
).
getObjects
();
Map
<
String
,
AuthorizationGroup
>
adminGroupsByGroupId
=
new
HashMap
<>();
Map
<
String
,
AuthorizationGroup
>
adminGroupsByGroupId
=
new
HashMap
<>();
...
@@ -893,7 +898,7 @@ public class UserManager
...
@@ -893,7 +898,7 @@ public class UserManager
{
{
if
(
role
!=
null
)
if
(
role
!=
null
)
{
{
context
.
delete
(
roleAssignment
.
getId
()
);
context
.
delete
(
roleAssignment
);
context
.
report
.
unassignRoleFrom
(
groupId
,
roleAssignment
.
getRole
(),
permId
);
context
.
report
.
unassignRoleFrom
(
groupId
,
roleAssignment
.
getRole
(),
permId
);
}
}
if
(
userSpaceRole
!=
null
)
if
(
userSpaceRole
!=
null
)
...
@@ -1011,7 +1016,7 @@ public class UserManager
...
@@ -1011,7 +1016,7 @@ public class UserManager
String
userSpace
=
createCommonSpaceCode
(
groupCode
,
userId
.
toUpperCase
());
String
userSpace
=
createCommonSpaceCode
(
groupCode
,
userId
.
toUpperCase
());
if
(
space
!=
null
&&
space
.
getCode
().
startsWith
(
userSpace
))
if
(
space
!=
null
&&
space
.
getCode
().
startsWith
(
userSpace
))
{
{
context
.
delete
(
roleAssignment
.
getId
()
);
context
.
delete
(
roleAssignment
);
context
.
report
.
unassignRoleFrom
(
userId
,
roleAssignment
.
getRole
(),
space
.
getPermId
());
context
.
report
.
unassignRoleFrom
(
userId
,
roleAssignment
.
getRole
(),
space
.
getPermId
());
}
}
}
}
...
@@ -1478,9 +1483,15 @@ public class UserManager
...
@@ -1478,9 +1483,15 @@ public class UserManager
groupUpdates
.
add
(
groupUpdate
);
groupUpdates
.
add
(
groupUpdate
);
}
}
public
void
delete
(
I
RoleAssignment
Id
roleAssignment
Id
)
public
void
delete
(
RoleAssignment
roleAssignment
)
{
{
roleDeletions
.
add
(
roleAssignmentId
);
/*\
* The maintenance task should only remove role assignments created by itself
*/
if
(
roleAssignment
.
getRegistrator
().
getUserId
().
equals
(
"system"
))
{
roleDeletions
.
add
(
roleAssignment
.
getId
());
}
}
}
public
void
executeOperations
()
public
void
executeOperations
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment