From bacba3984c80fa86c48f7c477180c4b8fded0e69 Mon Sep 17 00:00:00 2001 From: Alfredo Oliviero Date: Fri, 23 Feb 2024 17:05:11 +0100 Subject: [PATCH] AuthorizationService excludes guest --- README.md | 3 +++ gcube/extra-resources/WEB-INF/application.yaml | 1 + src/main/java/org/gcube/service/helloworld/HelloWorld.java | 4 +++- .../{AuthorizedMethods.java => AuthorizationService.java} | 2 +- ...eAuthorization.java => ExcludeAuthorizationService.java} | 6 +++--- 5 files changed, 11 insertions(+), 5 deletions(-) rename src/main/java/org/gcube/service/helloworld/services/{AuthorizedMethods.java => AuthorizationService.java} (97%) rename src/main/java/org/gcube/service/helloworld/services/{ExcludeAuthorization.java => ExcludeAuthorizationService.java} (88%) diff --git a/README.md b/README.md index 52de1f2..b2fd3ba 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,9 @@ start the docker container test urls (replace {{TOKEN}} with your token): + +http://localhost:8080/helloworld/guest + http://localhost:8080/helloworld/details?gcube-token={{TOKEN}} http://localhost:8080/helloworld/hello/details?gcube-token={{TOKEN}} diff --git a/gcube/extra-resources/WEB-INF/application.yaml b/gcube/extra-resources/WEB-INF/application.yaml index 0c8814e..2972029 100644 --- a/gcube/extra-resources/WEB-INF/application.yaml +++ b/gcube/extra-resources/WEB-INF/application.yaml @@ -4,4 +4,5 @@ version: 1.0.0 description: HelloWorld Service excludes: - path: /excluded + - path: /guest - path: /api-docs/* \ No newline at end of file diff --git a/src/main/java/org/gcube/service/helloworld/HelloWorld.java b/src/main/java/org/gcube/service/helloworld/HelloWorld.java index d3be3ab..54e9880 100644 --- a/src/main/java/org/gcube/service/helloworld/HelloWorld.java +++ b/src/main/java/org/gcube/service/helloworld/HelloWorld.java @@ -9,6 +9,7 @@ import javax.ws.rs.core.Application; import org.gcube.service.helloworld.services.AuthorizedMethods; import org.gcube.service.helloworld.services.ExcludeAuthorization; import org.gcube.service.helloworld.services.HelloService; +import org.gcube.service.helloworld.services.TestAuthorizationService; @ApplicationPath("") @@ -18,8 +19,9 @@ public class HelloWorld extends Application { final Set> classes = new HashSet>(); // register resources classes implementing Servlets classes.add(HelloService.class); - classes.add(AuthorizedMethods.class); classes.add(ExcludeAuthorization.class); + classes.add(TestAuthorizationService.class); + return classes; } } diff --git a/src/main/java/org/gcube/service/helloworld/services/AuthorizedMethods.java b/src/main/java/org/gcube/service/helloworld/services/AuthorizationService.java similarity index 97% rename from src/main/java/org/gcube/service/helloworld/services/AuthorizedMethods.java rename to src/main/java/org/gcube/service/helloworld/services/AuthorizationService.java index be21220..4c877da 100644 --- a/src/main/java/org/gcube/service/helloworld/services/AuthorizedMethods.java +++ b/src/main/java/org/gcube/service/helloworld/services/AuthorizationService.java @@ -11,7 +11,7 @@ import org.gcube.common.security.secrets.Secret; import org.gcube.smartgears.utils.InnerMethodName; @Path("auth") -public class AuthorizedMethods { +public class TestAuthorizationService { private static final String ALLOWED_ROLE = "myRole"; private static final String ALLOWED_ROLE_ORG = "OrganizationMember"; diff --git a/src/main/java/org/gcube/service/helloworld/services/ExcludeAuthorization.java b/src/main/java/org/gcube/service/helloworld/services/ExcludeAuthorizationService.java similarity index 88% rename from src/main/java/org/gcube/service/helloworld/services/ExcludeAuthorization.java rename to src/main/java/org/gcube/service/helloworld/services/ExcludeAuthorizationService.java index f65d3cf..806ce88 100644 --- a/src/main/java/org/gcube/service/helloworld/services/ExcludeAuthorization.java +++ b/src/main/java/org/gcube/service/helloworld/services/ExcludeAuthorizationService.java @@ -6,10 +6,10 @@ import javax.ws.rs.Path; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@Path("excluded") -public class ExcludeAuthorization { +@Path("guest") +public class ExcludeAuthorizationService { - private final Logger logger = LoggerFactory.getLogger(ExcludeAuthorization.class); + private final Logger logger = LoggerFactory.getLogger(ExcludeAuthorizationService.class); /**