This commit is contained in:
Colin McDonald 2016-05-06 09:30:47 -04:00
parent 18c264995c
commit 979b82e90e
6 changed files with 34 additions and 13 deletions

View File

@ -18,4 +18,5 @@ librato.email=cmcdonald.main@gmail.com
librato.apiKey=a818c3eca8a59d6d9cf76dc9f0d237c6aa97f257c482ce3363cf55a5431bc153
bugsnag.apiKey=0e47fba8b825416b7cbc839066184509
auth.permittedUserRanks=developer,owner
auth.websiteApiKey=RVbp4hY6sCFVaf
auth.websiteApiKey=RVbp4hY6sCFVaf
auth.bungeeCordApiKey=6d9cf76dc9f0d23

View File

@ -13,6 +13,8 @@ import net.frozenorb.apiv3.filters.*;
import net.frozenorb.apiv3.routes.GETDump;
import net.frozenorb.apiv3.routes.GETWhoAmI;
import net.frozenorb.apiv3.routes.NotFound;
import net.frozenorb.apiv3.routes.POSTMetrics;
import net.frozenorb.apiv3.routes.servers.POSTServerHeartbeat;
import net.frozenorb.apiv3.routes.announcements.GETAnnouncements;
import net.frozenorb.apiv3.routes.auditLog.GETAuditLog;
import net.frozenorb.apiv3.routes.chatFilterList.GETChatFilterList;
@ -153,6 +155,7 @@ public final class APIv3 {
// TODO: The commented out routes
post("/metrics", new POSTMetrics(), gson::toJson);
get("/announcements", new GETAnnouncements(), gson::toJson);
get("/auditLog", new GETAuditLog(), gson::toJson);
get("/chatFilterList", new GETChatFilterList(), gson::toJson);
@ -188,7 +191,6 @@ public final class APIv3 {
get("/server/:id", new GETServer(), gson::toJson);
get("/servers", new GETServers(), gson::toJson);
post("/server/heartbeat", new POSTServerHeartbeat(), gson::toJson);
post("/server/metrics", new POSTServerMetrics(), gson::toJson);
post("/server", new POSTServer(), gson::toJson);
//put("/server/:id", new PUTServer(), gson::toJson);
delete("/server/:id", new DELETEServer(), gson::toJson);

View File

@ -2,6 +2,6 @@ package net.frozenorb.apiv3.actors;
public enum ActorType {
WEBSITE, SERVER, USER, UNKNOWN
WEBSITE, BUNGEECORD, SERVER, USER, UNKNOWN
}

View File

@ -0,0 +1,19 @@
package net.frozenorb.apiv3.actors;
import net.frozenorb.apiv3.models.Server;
public final class BungeeCordActor implements Actor {
public boolean isAuthorized() {
return true;
}
public String getName() {
return "BungeeCord";
}
public ActorType getType() {
return ActorType.BUNGEECORD;
}
}

View File

@ -72,6 +72,13 @@ public final class ActorAttributeFilter implements Filter {
if (givenKey.equals(properKey)) {
return new ServerActor(server);
}
} else if (type.equals("BUngeeCord") && split.length == 2) {
String givenKey = split[1];
String properKey = APIv3.getConfig().getProperty("auth.bungeeCordApiKey");
if (givenKey.equals(properKey)) {
return new BungeeCordActor();
}
}
}

View File

@ -1,4 +1,4 @@
package net.frozenorb.apiv3.routes.servers;
package net.frozenorb.apiv3.routes;
import com.google.common.collect.ImmutableMap;
import net.frozenorb.apiv3.actors.Actor;
@ -9,17 +9,9 @@ import spark.Request;
import spark.Response;
import spark.Route;
public final class POSTServerMetrics implements Route {
public final class POSTMetrics implements Route {
public Object handle(Request req, Response res) {
Actor actor = req.attribute("actor");
if (actor.getType() != ActorType.SERVER) {
return ErrorUtils.serverOnly();
}
Server actorServer = Server.byId(actor.getName());
//LibratoBatch batch = new LibratoBatch();
return ImmutableMap.of();