Skip to content
Snippets Groups Projects
Commit f8857adc authored by Félix  Sidokhine's avatar Félix Sidokhine Committed by Adrien Béraud
Browse files

fix for backward compatibility with simple HTTP auth when registering a device

Change-Id: I9862054b7ca53e4e4b03d40da45130d0c6a5e876
parent 5df92b11
No related branches found
No related tags found
No related merge requests found
......@@ -108,7 +108,6 @@ public class DeviceServlet extends HttpServlet {
@Override
@ScopedServletMethod(securityGroups = {AccessLevel.USER})
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//super.doPost(req,resp);
DeviceRegistrationRequest request = JsonIterator.deserialize(req.getInputStream().readAllBytes(), DeviceRegistrationRequest.class);
DeviceRegistrationResponse devResponse = RegisterDeviceFlow.registerDevice(req.getAttribute("username").toString(),request);
if(devResponse != null) resp.getOutputStream().write(JsonStream.serialize(devResponse).getBytes());
......
......@@ -67,6 +67,14 @@ public class ApiFilter implements Filter {
//authorization header instead of tokens.
if(request.getHeader("authorization") != null){
AuthTokenResponse res = processUsernamePasswordAuth(request.getHeader("authorization"));
try {
SignedJWT token = SignedJWT.parse(res.getAccess_token());
request.setAttribute("username", token.getJWTClaimsSet().getSubject());
request.setAttribute("accessLevel",AccessLevel.valueOf(token.getJWTClaimsSet().getClaim("scope").toString()));
}
catch (Exception e){
log.error("Could not authenticate user!");
}
if(res != null) authsuccess = true;
}
else if (request.getHeader("Bearer") != null) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment