I secured my auth-service with a jwt and when i request a ressource with the jwt in the header everything works fine. After I implemented a Eureka Service Discovery and a Zuul Gateway and try to request a secured ressource I get the following response:
{
"timestamp": "2019-06-04T15:28:31.690+0000",
"status": 403,
"error": "Forbidden",
"message": "Access Denied",
"path": "/user"
}
So this meesage only occurs when I send the request through the Gateway. It is also possible to get unsecured ressources through the gatway, there is only a problem with secured ressources.
Security Configuration in Auth Service:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf()
.disable()
.cors()
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/signup").permitAll()
.antMatchers("/login").permitAll()
.antMatchers("/confirm-account").permitAll()
.antMatchers("/resendMail").permitAll()
.antMatchers("/validate/user").permitAll()
.antMatchers("/reset/password").permitAll()
.antMatchers("/reset-password").permitAll()
.antMatchers("/new/password").permitAll()
.anyRequest().authenticated()
.and()
.apply(new JWTConfigurer(this.tokenProvider));
}
application.properties in auth-service
spring.datasource.url=jdbc:postgresql://localhost:5432/gamificationdb
spring.datasource.username = postgres
spring.datasource.password = root
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto = update
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.main.allow-bean-definition-overriding=true
eureka.client.serviceUrl.defaultZone= http://localhost:8080/eureka/