I am working on combined authentication and resource server.
I tested and got the authentication working with a login page triggered by the redirect, token creation using authorization code etc all fine.
However when I turn on the resource server the redirct login page stops working with different security settings related problems.
I think it has to do with that both ResourceServerConfigurerAdapter AND the WebSecurityConfigurerAdapter has a configure(HttpSecurity http) method to override.
I tried using only one of them and even tried letting them both set the same settings etc but cannot get it to work properly.
For instance one of the problems I get is missing csrf in the model:
Exception evaluating SpringEL expression: "_csrf.parameterName" (login:45)
What is the recommended way of doing this?
The purpose of this server is to: - Act as an OAuth authentication server, mainly with authorization code flow which will show a login followed by an approval page to the user - Also host the REST API which the OAuth client will connect to using the access token to access resources for the logged in user
The security config looks like this:
http
.authorizeRequests()
.antMatchers("/login", "/logout.do").permitAll()
.antMatchers("/oauth/**").permitAll()
.antMatchers("/myservice/api/**").authenticated()
.and()
.formLogin()
.loginProcessingUrl("/login.do")
.usernameParameter("name")
.loginPage("/login")
.and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout.do"));
And the login page is a simple thymeleaf login page.