Update ReadMe

This commit is contained in:
Konstantinos Triantafyllou 2024-07-26 13:00:59 +03:00
parent 5d92e71cf2
commit 6cea9e373e
4 changed files with 5 additions and 39 deletions

View File

@ -1,6 +1,6 @@
# Authorization Library
Authorization library is a library that provides a Spring Security (4.x.x) process
Authorization library is a library that provides a Spring Security (6.x.x) process
in order to authorize the endpoints of a service base on OpenAIRE Authorities.
It can be used with two different session strategies, a stateless and
a Redis http session.
@ -19,7 +19,7 @@ user's session, but with a cost of an extra http request per request.
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>uoa-authorization-library</artifactId>
<version>2.1.2</version>
<version>3.0.0</version>
</dependency>
#### Spring Application/Configuration
@ -38,6 +38,7 @@ user's session, but with a cost of an extra http request per request.
authorization.security.userInfoUrl = http://<domain>/login-service/userInfo # Required, default ""
authorization.security.session=<session-cookie-name> # Default openAIRESession
authorization.security.domain=<domain-suffix> # e.g openaire.eu Default: di.uoa.gr
## Redis
@ -53,7 +54,7 @@ where session is stored.
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>uoa-authorization-library</artifactId>
<version>2.1.2</version>
<version>3.0.0</version>
<classifier>redis</classifier>
</dependency>
@ -74,7 +75,7 @@ where session is stored.
authorization.secuirty.redis.host=<redis-ip> # Default localhost
authorization.secuirty.redis.port=<redis-port> # Default 6379
authorization.secuirty.redis.password=<redis-password> # Default ""
authorization.security.domain=<domain-suffix> # e.g openaire.eu
authorization.security.domain=<domain-suffix> # e.g openaire.eu Default: di.uoa.gr
authorization.security.session=<session-cookie-name> # Default openAIRESession
@ -118,35 +119,3 @@ e.g
+ ")")
@RequestMapping(value = "{type}/{id}", method = RequestMethod.GET)
public Entity getEntity(@PathVariable("type") String type, @PathVariable("id") String id) {}
## Spring Security (5.x.x) - Spring boot (2.x.x)
Because of MitreID dependency, in order to use this library
with redis HttpSession, service has to use spring security (4.x.x).
The only way to use this library in a project with spring security 5.x.x
is the Stateless strategy with the following modification in Application
class:
import eu.dnetlib.uoaauthorizationlibrary.configuration.AuthorizationConfiguration;
@PropertySources({@PropertySource("classpath:authorization.properties")})
@Import(AuthorizationConfiguration.class)
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedMethods("GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS")
.allowedOriginPatterns("*")
.allowCredentials(true);
}
};
}
}

View File

@ -6,7 +6,6 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

View File

@ -18,7 +18,6 @@ public class AuthorizationFilter implements Filter {
this.authorizationProvider = authorizationProvider;
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
if (request instanceof HttpServletRequest req) {

View File

@ -24,7 +24,6 @@ public class WebSecurityConfig {
this.filter = filter;
}
@Bean
public EntryPoint entryPoint() {
return new EntryPoint();