Commit cad8e3d0 authored by Grzegorz Pietrusza's avatar Grzegorz Pietrusza

clenaup auth endpoint

parent 92fb7719
...@@ -5,6 +5,7 @@ import com.telephoners.krakyournet.ctf.beans.Team; ...@@ -5,6 +5,7 @@ import com.telephoners.krakyournet.ctf.beans.Team;
import com.telephoners.krakyournet.ctf.beans.User; import com.telephoners.krakyournet.ctf.beans.User;
import com.telephoners.krakyournet.ctf.repositories.TeamsRepository; import com.telephoners.krakyournet.ctf.repositories.TeamsRepository;
import io.dropwizard.auth.Auth; import io.dropwizard.auth.Auth;
import org.apache.commons.io.FileUtils;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
...@@ -14,6 +15,8 @@ import javax.ws.rs.Produces; ...@@ -14,6 +15,8 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.io.File;
import java.io.IOException;
import java.util.Optional; import java.util.Optional;
@Singleton @Singleton
...@@ -44,16 +47,15 @@ public class UtilResource ...@@ -44,16 +47,15 @@ public class UtilResource
return responseBuilder.build(); return responseBuilder.build();
} }
//todo: cleanup
@GET @GET
@Path("/auth") @Path("/auth")
public Response auth(@Auth User user) public Response auth(@Auth User user) throws IOException
{ {
String jsRedirect = "<script type=\"text/javascript\">\n" + String redirectHtml = new String(FileUtils.readFileToByteArray(new File("service/src/main/resources/assets/redirect.html")));
"<!--\n" + return Response.ok()
"window.location = \"http://\" + window.location.host + \"/page\"\n" + .entity(redirectHtml)
"//-->\n" + .header(HttpHeaders.CONTENT_TYPE, "text/html")
"</script>"; .header(HttpHeaders.WWW_AUTHENTICATE, "Basic")
return Response.ok().entity(jsRedirect).header(HttpHeaders.CONTENT_TYPE, "text/html").header(HttpHeaders.WWW_AUTHENTICATE, "Basic").build(); .build();
} }
} }
<!DOCTYPE html>
<html lang="en" ng-app="ctfApp">
<head>
</head>
<script type="text/javascript">
window.location = "http://" + window.location.host + "/page";
</script>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment