Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IA2
GMS
Commits
e3dd2142
Commit
e3dd2142
authored
Oct 30, 2020
by
Sonia Zorba
Browse files
Bugfix
parent
f038285c
Pipeline
#581
passed with stages
in 30 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gms/pom.xml
View file @
e3dd2142
...
...
@@ -40,7 +40,7 @@
</dependency>
<dependency>
<groupId>
${project.groupId}
</groupId>
<artifactId>
A
uth
L
ib
</artifactId>
<artifactId>
a
uth
-l
ib
</artifactId>
<version>
2.0.0-SNAPSHOT
</version>
</dependency>
<dependency>
...
...
gms/src/main/java/it/inaf/ia2/gms/controller/HomePageController.java
View file @
e3dd2142
...
...
@@ -82,6 +82,10 @@ public class HomePageController {
@GetMapping
(
value
=
"/"
,
produces
=
MediaType
.
TEXT_HTML_VALUE
)
public
String
index
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
// This page MUST NOT be cached to avoid losing the login redirect
response
.
setHeader
(
"Cache-Control"
,
"no-store, must-revalidate"
);
response
.
setHeader
(
"Expires"
,
"0"
);
Optional
<
List
<
InvitedRegistration
>>
optReg
=
invitedRegistrationManager
.
completeInvitedRegistrationIfNecessary
();
if
(
optReg
.
isPresent
())
{
request
.
setAttribute
(
"invited-registrations"
,
optReg
.
get
());
...
...
@@ -95,6 +99,6 @@ public class HomePageController {
public
void
logout
(
HttpSession
httpSession
,
HttpServletResponse
response
)
throws
IOException
{
httpSession
.
invalidate
();
String
baseUrl
=
ServletUriComponentsBuilder
.
fromCurrentContextPath
().
build
().
toUriString
();
response
.
sendRedirect
(
baseUrl
);
response
.
sendRedirect
(
baseUrl
+
"/"
);
}
}
gms/src/main/java/it/inaf/ia2/gms/controller/JWTWebServiceController.java
View file @
e3dd2142
...
...
@@ -239,15 +239,15 @@ public class JWTWebServiceController {
@GetMapping
(
value
=
{
"/permission/{group:.+}"
,
"/permission"
},
produces
=
MediaType
.
TEXT_PLAIN_VALUE
)
public
void
getUserPermission
(
@PathVariable
(
"group"
)
Optional
<
String
>
groupNames
,
@RequestParam
(
"user_id"
)
Optional
<
String
>
userId
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
GroupEntity
groupEntity
=
getGroupFromNames
(
extractGroupNames
(
groupNames
));
if
(
userId
.
isPresent
())
{
try
(
PrintWriter
pw
=
new
PrintWriter
(
response
.
getOutputStream
()))
{
for
(
UserPermission
userPermission
:
searchService
.
getUserPermission
(
userId
.
get
(),
permissionsManager
.
getCurrentUserPermissions
(
g
etRoot
()
)))
{
for
(
UserPermission
userPermission
:
searchService
.
getUserPermission
(
groupEntity
,
userId
.
get
(),
permissionsManager
.
getCurrentUserPermissions
(
g
roupEntity
)))
{
String
group
=
String
.
join
(
"."
,
userPermission
.
getGroupCompleteName
());
pw
.
println
(
group
+
" "
+
userPermission
.
getPermission
());
}
}
}
else
{
GroupEntity
groupEntity
=
getGroupFromNames
(
extractGroupNames
(
groupNames
));
try
(
PrintWriter
pw
=
new
PrintWriter
(
response
.
getOutputStream
()))
{
for
(
it
.
inaf
.
ia2
.
gms
.
model
.
UserPermission
up
:
permissionsManager
.
getAllPermissions
(
groupEntity
))
{
pw
.
println
(
up
.
getUser
().
getId
()
+
" "
+
up
.
getPermission
());
...
...
gms/src/main/java/it/inaf/ia2/gms/service/SearchService.java
View file @
e3dd2142
...
...
@@ -115,7 +115,7 @@ public class SearchService {
sortByGroupCompleteName
(
groups
);
response
.
setGroups
(
groups
);
List
<
UserPermission
>
permissions
=
getUserPermission
(
targetUserId
,
actorPermissions
);
List
<
UserPermission
>
permissions
=
getUserPermission
(
groupsManager
.
getRoot
(),
targetUserId
,
actorPermissions
);
sortByGroupCompleteName
(
permissions
);
response
.
setPermissions
(
permissions
);
...
...
@@ -147,12 +147,12 @@ public class SearchService {
.
collect
(
Collectors
.
toList
());
}
public
List
<
UserPermission
>
getUserPermission
(
String
targetUserId
,
List
<
PermissionEntity
>
actorPermissions
)
{
public
List
<
UserPermission
>
getUserPermission
(
GroupEntity
group
,
String
targetUserId
,
List
<
PermissionEntity
>
actorPermissions
)
{
List
<
UserPermission
>
permissions
=
new
ArrayList
<>();
// Super-admin user is able to see also other user permissions
PermissionUtils
.
getGroupPermission
(
group
sManager
.
getRoot
()
,
actorPermissions
).
ifPresent
(
permission
->
{
PermissionUtils
.
getGroupPermission
(
group
,
actorPermissions
).
ifPresent
(
permission
->
{
if
(
permission
.
equals
(
Permission
.
ADMIN
))
{
Map
<
String
,
PermissionEntity
>
targetUserPermissions
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment