Added an example of ecluded method

This commit is contained in:
lucio 2024-02-23 15:20:22 +01:00
parent 6ce907d32d
commit 7e53d716fc
4 changed files with 35 additions and 1 deletions

View File

@ -1,4 +1,4 @@
FROM smartgears-distribution:4.0.0-SNAPSHOT-java11-tomcat9
FROM d4science/smartgears-distribution:4.0.0-SNAPSHOT-java11-tomcat9
COPY ./docker/logback.xml /etc/
COPY ./docker/container.ini /etc/

View File

@ -3,4 +3,5 @@ group: org.gcube.service
version: 1.0.0
description: HelloWorld Service
excludes:
- path: /excluded
- path: /api-docs/*

View File

@ -7,6 +7,7 @@ import javax.ws.rs.ApplicationPath;
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;
@ -18,6 +19,7 @@ public class HelloWorld extends Application {
// register resources classes implementing Servlets
classes.add(HelloService.class);
classes.add(AuthorizedMethods.class);
classes.add(ExcludeAuthorization.class);
return classes;
}
}

View File

@ -0,0 +1,31 @@
package org.gcube.service.helloworld.services;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Path("excluded")
public class ExcludeAuthorization {
private final Logger logger = LoggerFactory.getLogger(ExcludeAuthorization.class);
/**
* this method doesn't need authorization and the SecretManagerProvider is null
* see to implement this behavior add to excludes section in your application.yaml
*
* - path: /{path-to-your-method-path}
*
* example for this method
*
* - path: /excluded
*
*/
@GET
public String exludedMethod() {
logger.info("executed whithout any authorization");
return "executed whithout any authorization";
}
}