From e9b80d4f0a3b329881c89daa0fbd749872b40752 Mon Sep 17 00:00:00 2001 From: Marco Fargetta Date: Thu, 6 Jun 2024 17:05:29 +0200 Subject: [PATCH] Move REST endpoint to v1 The current REST implemenation is associated to /v1 path and the /rest path is a redirect to the /v1. This would make easier to switch between REST implementations. --- .../acme/server/ACMEApplication.java | 2 +- base/acme/webapps/acme/WEB-INF/web.xml | 5 +++ base/ca/shared/webapps/ca/WEB-INF/web.xml | 8 +++++ .../server/ca/rest/CAApplication.java | 2 +- .../org/dogtagpki/est/ESTApplication.java | 2 +- base/est/webapps/est/WEB-INF/web.xml | 3 ++ base/kra/shared/webapps/kra/WEB-INF/web.xml | 7 +++- .../server/kra/rest/KRAApplication.java | 2 +- base/ocsp/shared/webapps/ocsp/WEB-INF/web.xml | 5 +++ .../server/ocsp/rest/OCSPApplication.java | 2 +- .../dogtagpki/server/rest/PKIApplication.java | 2 +- base/tks/shared/webapps/tks/WEB-INF/web.xml | 4 +++ .../server/tks/rest/TKSApplication.java | 2 +- .../conf/Catalina/localhost/rewrite.config | 33 ++++++++++--------- base/tps/shared/webapps/tps/WEB-INF/web.xml | 10 ++++++ .../server/tps/rest/TPSApplication.java | 2 +- 16 files changed, 67 insertions(+), 24 deletions(-) diff --git a/base/acme/src/main/java/org/dogtagpki/acme/server/ACMEApplication.java b/base/acme/src/main/java/org/dogtagpki/acme/server/ACMEApplication.java index 28f895455f5..3c0f2d6b30c 100644 --- a/base/acme/src/main/java/org/dogtagpki/acme/server/ACMEApplication.java +++ b/base/acme/src/main/java/org/dogtagpki/acme/server/ACMEApplication.java @@ -14,7 +14,7 @@ /** * @author Endi S. Dewata */ -@ApplicationPath("/rest") +@ApplicationPath("/v1") public class ACMEApplication extends Application { public static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ACMEApplication.class); diff --git a/base/acme/webapps/acme/WEB-INF/web.xml b/base/acme/webapps/acme/WEB-INF/web.xml index 2b108970d04..ef9f967a735 100644 --- a/base/acme/webapps/acme/WEB-INF/web.xml +++ b/base/acme/webapps/acme/WEB-INF/web.xml @@ -12,6 +12,7 @@ SPDX-License-Identifier: GPL-2.0-or-later Allow somebody with credentials to log in /rest/login + /v1/login POST @@ -26,6 +27,7 @@ SPDX-License-Identifier: GPL-2.0-or-later Allow anybody to get login information /rest/login + /v1/login POST @@ -38,6 +40,7 @@ SPDX-License-Identifier: GPL-2.0-or-later Logout Service /rest/logout + /v1/logout CONFIDENTIAL @@ -48,6 +51,7 @@ SPDX-License-Identifier: GPL-2.0-or-later Allow administrators to enable ACME services /rest/enable + /v1/enable Administrators @@ -62,6 +66,7 @@ SPDX-License-Identifier: GPL-2.0-or-later Allow administrators to disable ACME services /rest/disable + /v1/disable Administrators diff --git a/base/ca/shared/webapps/ca/WEB-INF/web.xml b/base/ca/shared/webapps/ca/WEB-INF/web.xml index e6d26f34ef8..a0a08e1b7de 100644 --- a/base/ca/shared/webapps/ca/WEB-INF/web.xml +++ b/base/ca/shared/webapps/ca/WEB-INF/web.xml @@ -7,6 +7,7 @@ Account Services /rest/account/* + /v1/account/* * @@ -20,6 +21,7 @@ Admin Services /rest/admin/* + /v1/admin/* * @@ -33,6 +35,7 @@ Agent Services /rest/agent/* + /v1/agent/* /v2/agent/* @@ -47,6 +50,7 @@ Audit /rest/audit/* + /v1/audit/* * @@ -60,6 +64,7 @@ Authority Services /rest/authorities/* + /v1/authorities/* CONFIDENTIAL @@ -70,6 +75,7 @@ Security Domain Services /rest/securityDomain/installToken + /v1/securityDomain/installToken * @@ -83,6 +89,7 @@ Self Tests /rest/selftests/* + /v1/selftests/* * @@ -96,6 +103,7 @@ Profile Services /rest/profiles/* + /v1/profiles/* CONFIDENTIAL diff --git a/base/ca/src/main/java/org/dogtagpki/server/ca/rest/CAApplication.java b/base/ca/src/main/java/org/dogtagpki/server/ca/rest/CAApplication.java index e402a90b0b0..0aedcb74443 100644 --- a/base/ca/src/main/java/org/dogtagpki/server/ca/rest/CAApplication.java +++ b/base/ca/src/main/java/org/dogtagpki/server/ca/rest/CAApplication.java @@ -21,7 +21,7 @@ import org.dogtagpki.server.rest.SessionContextInterceptor; import org.dogtagpki.server.rest.UserService; -@ApplicationPath("/rest") +@ApplicationPath("/v1") public class CAApplication extends Application { public static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(CAApplication.class); diff --git a/base/est/src/main/java/org/dogtagpki/est/ESTApplication.java b/base/est/src/main/java/org/dogtagpki/est/ESTApplication.java index 989664fcd91..c2dc118a571 100644 --- a/base/est/src/main/java/org/dogtagpki/est/ESTApplication.java +++ b/base/est/src/main/java/org/dogtagpki/est/ESTApplication.java @@ -13,7 +13,7 @@ import org.dogtagpki.server.rest.PKIExceptionMapper; -@ApplicationPath("/rest") +@ApplicationPath("/v1") public class ESTApplication extends Application { public static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ESTApplication.class); diff --git a/base/est/webapps/est/WEB-INF/web.xml b/base/est/webapps/est/WEB-INF/web.xml index 308b99469a9..1a310fb0d5f 100644 --- a/base/est/webapps/est/WEB-INF/web.xml +++ b/base/est/webapps/est/WEB-INF/web.xml @@ -13,6 +13,7 @@ SPDX-License-Identifier: GPL-2.0-or-later Require TLS for all resources /rest/* + /v1/* GET @@ -42,6 +43,7 @@ SPDX-License-Identifier: GPL-2.0-or-later Require authenticated client for POST resources /rest/* + /v1/* POST @@ -57,6 +59,7 @@ SPDX-License-Identifier: GPL-2.0-or-later Reject unused methods /rest/* + /v1/* GET POST diff --git a/base/kra/shared/webapps/kra/WEB-INF/web.xml b/base/kra/shared/webapps/kra/WEB-INF/web.xml index 7ee15aa2bd7..279cf776fc9 100644 --- a/base/kra/shared/webapps/kra/WEB-INF/web.xml +++ b/base/kra/shared/webapps/kra/WEB-INF/web.xml @@ -7,6 +7,7 @@ Account Services /rest/account/* + /v1/account/* * @@ -20,6 +21,7 @@ Admin Services /rest/admin/* + /v1/admin/* * @@ -32,7 +34,7 @@ Agent Services - /rest/agent/* + /v1/agent/* * @@ -46,6 +48,7 @@ Audit /rest/audit/* + /v1/audit/* * @@ -59,6 +62,7 @@ Security Domain Services /rest/securityDomain/installToken + /v1/securityDomain/installToken * @@ -72,6 +76,7 @@ Self Tests /rest/selftests/* + /v1/selftests/* * diff --git a/base/kra/src/main/java/org/dogtagpki/server/kra/rest/KRAApplication.java b/base/kra/src/main/java/org/dogtagpki/server/kra/rest/KRAApplication.java index b61bfc70690..1183f7284c1 100644 --- a/base/kra/src/main/java/org/dogtagpki/server/kra/rest/KRAApplication.java +++ b/base/kra/src/main/java/org/dogtagpki/server/kra/rest/KRAApplication.java @@ -20,7 +20,7 @@ import org.dogtagpki.server.rest.SessionContextInterceptor; import org.dogtagpki.server.rest.UserService; -@ApplicationPath("/rest") +@ApplicationPath("/v1") public class KRAApplication extends Application { public static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(KRAApplication.class); diff --git a/base/ocsp/shared/webapps/ocsp/WEB-INF/web.xml b/base/ocsp/shared/webapps/ocsp/WEB-INF/web.xml index 4c34e7cb6a8..403a408c007 100644 --- a/base/ocsp/shared/webapps/ocsp/WEB-INF/web.xml +++ b/base/ocsp/shared/webapps/ocsp/WEB-INF/web.xml @@ -11,6 +11,7 @@ Account Services /rest/account/* + /v1/account/* * @@ -24,6 +25,7 @@ Admin Services /rest/admin/* + /v1/admin/* * @@ -37,6 +39,7 @@ Audit /rest/audit/* + /v1/audit/* * @@ -50,6 +53,7 @@ Security Domain Services /rest/securityDomain/installToken + /v1/securityDomain/installToken * @@ -63,6 +67,7 @@ Self Tests /rest/selftests/* + /v1/selftests/* * diff --git a/base/ocsp/src/main/java/org/dogtagpki/server/ocsp/rest/OCSPApplication.java b/base/ocsp/src/main/java/org/dogtagpki/server/ocsp/rest/OCSPApplication.java index de4031796d9..4f8cb257ac4 100644 --- a/base/ocsp/src/main/java/org/dogtagpki/server/ocsp/rest/OCSPApplication.java +++ b/base/ocsp/src/main/java/org/dogtagpki/server/ocsp/rest/OCSPApplication.java @@ -19,7 +19,7 @@ import org.dogtagpki.server.rest.SessionContextInterceptor; import org.dogtagpki.server.rest.UserService; -@ApplicationPath("/rest") +@ApplicationPath("/v1") public class OCSPApplication extends Application { public static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(OCSPApplication.class); diff --git a/base/server-webapp/src/main/java/org/dogtagpki/server/rest/PKIApplication.java b/base/server-webapp/src/main/java/org/dogtagpki/server/rest/PKIApplication.java index db7d5e18f7d..b6b32a9aa68 100644 --- a/base/server-webapp/src/main/java/org/dogtagpki/server/rest/PKIApplication.java +++ b/base/server-webapp/src/main/java/org/dogtagpki/server/rest/PKIApplication.java @@ -24,7 +24,7 @@ import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; -@ApplicationPath("/rest") +@ApplicationPath("/v1") public class PKIApplication extends Application { private Set singletons = new LinkedHashSet<>(); diff --git a/base/tks/shared/webapps/tks/WEB-INF/web.xml b/base/tks/shared/webapps/tks/WEB-INF/web.xml index c0410907a53..64f77c864f3 100644 --- a/base/tks/shared/webapps/tks/WEB-INF/web.xml +++ b/base/tks/shared/webapps/tks/WEB-INF/web.xml @@ -11,6 +11,7 @@ Account Services /rest/account/* + /v1/account/* * @@ -24,6 +25,7 @@ Admin Services /rest/admin/* + /v1/admin/* * @@ -37,6 +39,7 @@ Audit /rest/audit/* + /v1/audit/* * @@ -50,6 +53,7 @@ Self Tests /rest/selftests/* + /v1/selftests/* * diff --git a/base/tks/src/main/java/org/dogtagpki/server/tks/rest/TKSApplication.java b/base/tks/src/main/java/org/dogtagpki/server/tks/rest/TKSApplication.java index 372822548d7..88adbc80bee 100644 --- a/base/tks/src/main/java/org/dogtagpki/server/tks/rest/TKSApplication.java +++ b/base/tks/src/main/java/org/dogtagpki/server/tks/rest/TKSApplication.java @@ -18,7 +18,7 @@ import org.dogtagpki.server.rest.SessionContextInterceptor; import org.dogtagpki.server.rest.UserService; -@ApplicationPath("/rest") +@ApplicationPath("/v1") public class TKSApplication extends Application { private Set singletons = new LinkedHashSet<>(); diff --git a/base/tomcat-9.0/conf/Catalina/localhost/rewrite.config b/base/tomcat-9.0/conf/Catalina/localhost/rewrite.config index 50f5b4bbc2a..2511bebf91e 100644 --- a/base/tomcat-9.0/conf/Catalina/localhost/rewrite.config +++ b/base/tomcat-9.0/conf/Catalina/localhost/rewrite.config @@ -1,18 +1,21 @@ # ACME -RewriteRule ^/acme/login$ /acme/rest/login -RewriteRule ^/acme/logout$ /acme/rest/logout -RewriteRule ^/acme/enable$ /acme/rest/enable -RewriteRule ^/acme/disable$ /acme/rest/disable -RewriteRule ^/acme/directory$ /acme/rest/directory -RewriteRule ^/acme/new-nonce$ /acme/rest/new-nonce -RewriteRule ^/acme/new-account$ /acme/rest/new-account -RewriteRule ^/acme/new-order$ /acme/rest/new-order -RewriteRule ^/acme/authz/(.*)$ /acme/rest/authz/$1 -RewriteRule ^/acme/chall/(.*)$ /acme/rest/chall/$1 -RewriteRule ^/acme/order/(.*)$ /acme/rest/order/$1 -RewriteRule ^/acme/acct/(.*)$ /acme/rest/acct/$1 -RewriteRule ^/acme/cert/(.*)$ /acme/rest/cert/$1 -RewriteRule ^/acme/revoke-cert$ /acme/rest/revoke-cert +RewriteRule ^/acme/login$ /acme/v1/login +RewriteRule ^/acme/logout$ /acme/v1/logout +RewriteRule ^/acme/enable$ /acme/v1/enable +RewriteRule ^/acme/disable$ /acme/v1/disable +RewriteRule ^/acme/directory$ /acme/v1/directory +RewriteRule ^/acme/new-nonce$ /acme/v1/new-nonce +RewriteRule ^/acme/new-account$ /acme/v1/new-account +RewriteRule ^/acme/new-order$ /acme/v1/new-order +RewriteRule ^/acme/authz/(.*)$ /acme/v1/authz/$1 +RewriteRule ^/acme/chall/(.*)$ /acme/v1/chall/$1 +RewriteRule ^/acme/order/(.*)$ /acme/v1/order/$1 +RewriteRule ^/acme/acct/(.*)$ /acme/v1/acct/$1 +RewriteRule ^/acme/cert/(.*)$ /acme/v1/cert/$1 +RewriteRule ^/acme/revoke-cert$ /acme/v1/revoke-cert # EST -RewriteRule ^/.well-known/est/(.*)$ /est/rest/$1 +RewriteRule ^/.well-known/est/(.*)$ /est/v1/$1 + +# REST APIs +RewriteRule ^/(ca|tps|tks|ocsp|kra)/rest/(.*)$ /$1/v2/$2 diff --git a/base/tps/shared/webapps/tps/WEB-INF/web.xml b/base/tps/shared/webapps/tps/WEB-INF/web.xml index 3cc296edd46..51e4ed4c12d 100644 --- a/base/tps/shared/webapps/tps/WEB-INF/web.xml +++ b/base/tps/shared/webapps/tps/WEB-INF/web.xml @@ -11,6 +11,7 @@ Account Services /rest/account/* + /v1/account/* * @@ -24,6 +25,7 @@ Admin Services /rest/admin/* + /v1/admin/* * @@ -37,6 +39,7 @@ Audit /rest/audit/* + /v1/audit/* * @@ -50,6 +53,7 @@ Authenticators /rest/authenticators/* + /v1/authenticators/* * @@ -63,6 +67,7 @@ Configuration /rest/config/* + /v1/config/* * @@ -76,6 +81,7 @@ Connectors /rest/connectors/* + /v1/connectors/* * @@ -89,6 +95,7 @@ Profiles /rest/profiles/* + /v1/profiles/* * @@ -102,6 +109,7 @@ Profile Mappings /rest/profile-mappings/* + /v1/profile-mappings/* * @@ -115,6 +123,7 @@ Self Tests /rest/selftests/* + /v1/selftests/* * @@ -128,6 +137,7 @@ Token Services /rest/tokens/* + /v1/tokens/* * diff --git a/base/tps/src/main/java/org/dogtagpki/server/tps/rest/TPSApplication.java b/base/tps/src/main/java/org/dogtagpki/server/tps/rest/TPSApplication.java index 3feed1c547b..f5e67348923 100644 --- a/base/tps/src/main/java/org/dogtagpki/server/tps/rest/TPSApplication.java +++ b/base/tps/src/main/java/org/dogtagpki/server/tps/rest/TPSApplication.java @@ -39,7 +39,7 @@ /** * @author Endi S. Dewata */ -@ApplicationPath("/rest") +@ApplicationPath("/v1") public class TPSApplication extends Application { private Set singletons = new LinkedHashSet<>();