diff --git a/src/main/java/io/supertokens/webserver/Webserver.java b/src/main/java/io/supertokens/webserver/Webserver.java index f27d256ac..89ead8fe1 100644 --- a/src/main/java/io/supertokens/webserver/Webserver.java +++ b/src/main/java/io/supertokens/webserver/Webserver.java @@ -43,11 +43,14 @@ import io.supertokens.webserver.api.oauth.OAuthClientListAPI; import io.supertokens.webserver.api.oauth.OAuthGetAuthConsentRequestAPI; import io.supertokens.webserver.api.oauth.OAuthGetAuthLoginRequestAPI; +import io.supertokens.webserver.api.oauth.OAuthGetAuthLogoutRequestAPI; import io.supertokens.webserver.api.oauth.OAuthRejectAuthConsentRequestAPI; import io.supertokens.webserver.api.oauth.OAuthRejectAuthLoginRequestAPI; +import io.supertokens.webserver.api.oauth.OAuthRejectAuthLogoutRequestAPI; import io.supertokens.webserver.api.oauth.CreateUpdateOrGetOAuthClientAPI; import io.supertokens.webserver.api.oauth.OAuthAcceptAuthConsentRequestAPI; import io.supertokens.webserver.api.oauth.OAuthAcceptAuthLoginRequestAPI; +import io.supertokens.webserver.api.oauth.OAuthAcceptAuthLogoutRequestAPI; import io.supertokens.webserver.api.oauth.OAuthTokenAPI; import io.supertokens.webserver.api.oauth.RemoveOAuthClientAPI; import io.supertokens.webserver.api.passwordless.*; @@ -290,6 +293,9 @@ private void setupRoutes() { addAPI(new OAuthGetAuthLoginRequestAPI(main)); addAPI(new OAuthAcceptAuthLoginRequestAPI(main)); addAPI(new OAuthRejectAuthLoginRequestAPI(main)); + addAPI(new OAuthGetAuthLogoutRequestAPI(main)); + addAPI(new OAuthAcceptAuthLogoutRequestAPI(main)); + addAPI(new OAuthRejectAuthLogoutRequestAPI(main)); StandardContext context = tomcatReference.getContext(); Tomcat tomcat = tomcatReference.getTomcat(); diff --git a/src/main/java/io/supertokens/webserver/api/oauth/OAuthAcceptAuthLogoutRequestAPI.java b/src/main/java/io/supertokens/webserver/api/oauth/OAuthAcceptAuthLogoutRequestAPI.java new file mode 100644 index 000000000..1533cb4d0 --- /dev/null +++ b/src/main/java/io/supertokens/webserver/api/oauth/OAuthAcceptAuthLogoutRequestAPI.java @@ -0,0 +1,45 @@ +package io.supertokens.webserver.api.oauth; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + +import io.supertokens.Main; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +public class OAuthAcceptAuthLogoutRequestAPI extends OAuthProxyBase { + + public OAuthAcceptAuthLogoutRequestAPI(Main main) { + super(main); + } + + @Override + public String getPath() { + return "/recipe/oauth/auth/requests/logout/accept"; + } + + @Override + public ProxyProps[] getProxyProperties(HttpServletRequest req, JsonObject input) { + return new ProxyProps[] { + new ProxyProps( + "PUT", // apiMethod + "PUT_JSON", // method + "/admin/oauth2/auth/requests/logout/accept", // path + true, // proxyToAdmin + true // camelToSnakeCaseConversion + ) + }; + } + + @Override + protected void handleResponseFromProxyPUT(HttpServletRequest req, HttpServletResponse resp, JsonObject input, int statusCode, Map> headers, String rawBody, JsonElement jsonBody) throws IOException, ServletException { + JsonObject response = jsonBody.getAsJsonObject(); + response.addProperty("status", "OK"); + sendJsonResponse(200, response, resp); + } +} diff --git a/src/main/java/io/supertokens/webserver/api/oauth/OAuthGetAuthLogoutRequestAPI.java b/src/main/java/io/supertokens/webserver/api/oauth/OAuthGetAuthLogoutRequestAPI.java new file mode 100644 index 000000000..90195c61f --- /dev/null +++ b/src/main/java/io/supertokens/webserver/api/oauth/OAuthGetAuthLogoutRequestAPI.java @@ -0,0 +1,48 @@ +package io.supertokens.webserver.api.oauth; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + +import io.supertokens.Main; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +public class OAuthGetAuthLogoutRequestAPI extends OAuthProxyBase { + + public OAuthGetAuthLogoutRequestAPI(Main main) { + super(main); + } + + @Override + public String getPath() { + return "/recipe/oauth/auth/requests/logout"; + } + + @Override + public ProxyProps[] getProxyProperties(HttpServletRequest req, JsonObject input) { + return new ProxyProps[] { + new ProxyProps( + "GET", // apiMethod + "GET", // method + "/admin/oauth2/auth/requests/logout", // path + true, // proxyToAdmin + true // camelToSnakeCaseConversion + ) + }; + } + + @Override + protected void handleResponseFromProxyGET(HttpServletRequest req, HttpServletResponse resp, int statusCode, + Map> headers, String rawBody, JsonElement jsonBody) + throws IOException, ServletException { + + JsonObject response = jsonBody.getAsJsonObject(); + response.addProperty("status", "OK"); + sendJsonResponse(200, response, resp); + } +} diff --git a/src/main/java/io/supertokens/webserver/api/oauth/OAuthRejectAuthLogoutRequestAPI.java b/src/main/java/io/supertokens/webserver/api/oauth/OAuthRejectAuthLogoutRequestAPI.java new file mode 100644 index 000000000..3f89171a5 --- /dev/null +++ b/src/main/java/io/supertokens/webserver/api/oauth/OAuthRejectAuthLogoutRequestAPI.java @@ -0,0 +1,45 @@ +package io.supertokens.webserver.api.oauth; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + +import io.supertokens.Main; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +public class OAuthRejectAuthLogoutRequestAPI extends OAuthProxyBase { + + public OAuthRejectAuthLogoutRequestAPI(Main main) { + super(main); + } + + @Override + public String getPath() { + return "/recipe/oauth/auth/requests/logout/reject"; + } + + @Override + public ProxyProps[] getProxyProperties(HttpServletRequest req, JsonObject input) { + return new ProxyProps[] { + new ProxyProps( + "PUT", // apiMethod + "PUT_JSON", // method + "/admin/oauth2/auth/requests/logout/reject", // path + true, // proxyToAdmin + true // camelToSnakeCaseConversion + ) + }; + } + + @Override + protected void handleResponseFromProxyPUT(HttpServletRequest req, HttpServletResponse resp, JsonObject input, int statusCode, Map> headers, String rawBody, JsonElement jsonBody) throws IOException, ServletException { + JsonObject response = jsonBody.getAsJsonObject(); + response.addProperty("status", "OK"); + sendJsonResponse(200, response, resp); + } +}