<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-forward-container">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<a moz-do-not-send="true"
href="http://stackoverflow.com/questions/33543672/keycloak-redirects-me-to-my-index-url-instead-of-to-the-requested-one">StackOverflow
link to the question</a><br>
<br>
I'm using Keycloak server (v 1.5.1) to perform an open-id-connect
like authentication to my service. I've set up a basic web
application which has two urls, the */index.html* one and other
one called /hello. I use Spring security, Spring boot and Spring
MVC for all of that. That's my pom.xml configuration:<br>
<br>
<br>
<?xml version="1.0" encoding="UTF-8"?><br>
<project xmlns=<a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="http://maven.apache.org/POM/4.0.0">"http://maven.apache.org/POM/4.0.0"</a>
xmlns:xsi=<a moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a><br>
xsi:schemaLocation=<a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="http://maven.apache.org/POM/4.0.0http://maven.apache.org/xsd/maven-4.0.0.xsd">"http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"</a>><br>
<modelVersion>4.0.0</modelVersion><br>
<br>
<groupId>com.keycloaktes</groupId><br>
<artifactId>keycloaktes</artifactId><br>
<version>0.0.1-SNAPSHOT</version><br>
<packaging>jar</packaging><br>
<br>
<name>demo</name><br>
<description>Demo project for Spring
Boot</description><br>
<br>
<parent><br>
<groupId>org.springframework.boot</groupId><br>
<artifactId>spring-boot-starter-parent</artifactId><br>
<version>1.2.7.RELEASE</version><br>
<relativePath /><br>
</parent><br>
<br>
<properties><br>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><br>
<java.version>1.7</java.version><br>
</properties><br>
<br>
<dependencies><br>
<dependency><br>
<groupId>org.springframework.boot</groupId><br>
<artifactId>spring-boot-starter-security</artifactId><br>
</dependency><br>
<br>
<dependency><br>
<groupId>org.springframework.boot</groupId><br>
<artifactId>spring-boot-starter-web</artifactId><br>
</dependency><br>
<br>
<dependency><br>
<groupId>org.springframework.boot</groupId><br>
<artifactId>spring-boot-starter-test</artifactId><br>
<scope>test</scope><br>
</dependency><br>
<br>
<dependency><br>
<groupId>org.keycloak</groupId><br>
<artifactId>keycloak-spring-security-adapter</artifactId><br>
<version>1.5.1.Final</version><br>
</dependency><br>
<br>
<dependency><br>
<groupId>org.keycloak</groupId><br>
<artifactId>keycloak-tomcat8-adapter</artifactId><br>
<version>1.5.1.Final</version><br>
</dependency><br>
<br>
</dependencies><br>
<br>
<br>
<build><br>
<plugins><br>
<plugin><br>
<groupId>org.springframework.boot</groupId><br>
<artifactId>spring-boot-maven-plugin</artifactId><br>
</plugin><br>
</plugins><br>
</build><br>
<br>
<br>
</project><br>
<br>
The issue comes when I address to /hello url when not logged in,
the keycloak login screen shows properly, but instead of
performing a redirection to /hello after successful login, it does
it to my /index.html page. That's how I've configured the security
adapter:<br>
<br>
<br>
<!-- language: lang-java --><br>
<br>
@Configuration<br>
@EnableWebSecurity<br>
@ComponentScan(basePackageClasses =
KeycloakSecurityComponents.class)<br>
public class SecurityConfig extends
KeycloakWebSecurityConfigurerAdapter {<br>
<br>
@Autowired<br>
public void configureGlobal(AuthenticationManagerBuilder
auth)<br>
throws Exception {<br>
auth.authenticationProvider(keycloakAuthenticationProvider());<br>
}<br>
<br>
/**<br>
* Defines the session authentication strategy.<br>
*/<br>
@Bean<br>
@Override<br>
protected SessionAuthenticationStrategy
sessionAuthenticationStrategy() {<br>
return new RegisterSessionAuthenticationStrategy(<br>
new SessionRegistryImpl());<br>
}<br>
<br>
@Bean<br>
public FilterRegistrationBean
keycloakAuthenticationProcessingFilterRegistrationBean(<br>
KeycloakAuthenticationProcessingFilter filter) {<br>
FilterRegistrationBean registrationBean = new
FilterRegistrationBean(<br>
filter);<br>
registrationBean.setEnabled(false);<br>
return registrationBean;<br>
}<br>
<br>
@Bean<br>
public FilterRegistrationBean
keycloakPreAuthActionsFilterRegistrationBean(<br>
KeycloakPreAuthActionsFilter filter) {<br>
FilterRegistrationBean registrationBean = new
FilterRegistrationBean(<br>
filter);<br>
registrationBean.setEnabled(false);<br>
return registrationBean;<br>
}<br>
<br>
@Override<br>
protected void configure(HttpSecurity http) throws
Exception {<br>
super.configure(http);<br>
http.authorizeRequests().antMatchers("/*").hasRole("ADMIN")<br>
.anyRequest().permitAll();<br>
http.csrf().disable();<br>
}<br>
}<br>
<br>
I've been trying enabling both the
`KeycloakAuthenticationProcessingFilter` and
`KeycloakPreAuthActionsFilter`, but result keeps the same. Does
anybody know how to solve the issue?<br>
</div>
<br>
</body>
</html>