Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-jams
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-jams
Commits
324890c0
Commit
324890c0
authored
4 years ago
by
Félix Sidokhine
Committed by
Adrien Béraud
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
added strong permission protection at device revocation level
Change-Id: I036656d3f95a9523dfcd7de7d6e009c9c587366c
parent
10557804
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
jams-server/src/main/java/net/jami/jams/server/servlets/api/auth/device/DeviceServlet.java
+9
-0
9 additions, 0 deletions
...i/jams/server/servlets/api/auth/device/DeviceServlet.java
with
9 additions
and
0 deletions
jams-server/src/main/java/net/jami/jams/server/servlets/api/auth/device/DeviceServlet.java
+
9
−
0
View file @
324890c0
...
...
@@ -42,6 +42,7 @@ import net.jami.jams.server.core.workflows.RegisterDeviceFlow;
import
net.jami.jams.server.core.workflows.RevokeDeviceFlow
;
import
java.io.IOException
;
import
java.util.stream.Collectors
;
import
static
net
.
jami
.
jams
.
server
.
Server
.
certificateAuthority
;
import
static
net
.
jami
.
jams
.
server
.
Server
.
dataStore
;
...
...
@@ -165,6 +166,14 @@ public class DeviceServlet extends HttpServlet {
protected
void
doDelete
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
super
.
doDelete
(
req
,
resp
);
String
deviceId
=
req
.
getPathInfo
().
replace
(
"/"
,
""
);
//If the device does not belong to the user throw a 403
StatementList
statementList
=
new
StatementList
();
StatementElement
statementElement
=
new
StatementElement
(
"owner"
,
"="
,
req
.
getAttribute
(
"username"
).
toString
(),
""
);
statementList
.
addStatement
(
statementElement
);
if
(
dataStore
.
getDeviceDao
().
getObjects
(
statementList
).
stream
().
filter
(
device
->
device
.
getDeviceId
().
equals
(
deviceId
)).
collect
(
Collectors
.
toList
()).
size
()
==
0
){
TomcatCustomErrorHandler
.
sendCustomError
(
resp
,
403
,
"You do not have sufficient rights to revoke this device!"
);
}
DeviceRevocationResponse
devResponse
=
RevokeDeviceFlow
.
revokeDevice
(
req
.
getAttribute
(
"username"
).
toString
(),
deviceId
);
if
(
devResponse
!=
null
)
resp
.
getOutputStream
().
write
(
JsonStream
.
serialize
(
devResponse
).
getBytes
());
TomcatCustomErrorHandler
.
sendCustomError
(
resp
,
500
,
"could not revoke device due to server-side error"
);
...
...
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