I've been studying the two spring boot books I know of: Spring Boot in Action 
by Walls and Learning Spring Boot by Turnquist and (I just discovered) Spring 
Boot Recipies by Antonov. None of these books discuss the development of a 
groovy REST service using spring boot. So lets assume I'm starting with the 
minimum from https://spring.io/guides/gs/spring-boot/: @RestController
class ThisWillActuallyRun {

    @RequestMapping("/")
    String home() {
        return "Hello World!"
    }

} How do I enhance this to do authentication (and eventually authorization)? 
After reading the first two books (could find much discussion in the cookbook) 
I'm wondering if I just append this class to the end of the groovy source code 
file? @Configuration@EnableGlobalMethodSecurity(securedEnabled = true)public 
class SecurityConfiguration extends WebSecurityConfigurerAdapter {@Autowired  
public void configureAuth(AuthenticationManagerBuilder auth) throws Exception { 
   auth.inMemoryAuthentication()....  }   @Override  protected void 
configure(HttpSecurity http) throws Exception {   
http.authorizeRequests().antMatchers(HttpMethod.GET,"/dir").permitAll().anyRequest().authenticated().and()
    .formLogin().loginPage("/login").failureUrl("/login?error=true"); // what 
does a REST controller do with a form? (1) If so, suppose it is only a REST 
service and not an MVC web page server. What do I do about the login forms? 
Ignore them?(2) Suppose it is a combination REST service (for AJAX maybe) and I 
want to serve a few MVC web pages too. (2a) How do I enhance the above groovy 
RestController to serve some MVC pages? Is it possible to have single class 
that services REST endpoints and MVC templates or do I need a separate 
controller class (in the same groovy source code file?) to serve MVC pages?(2b) 
Where (what directory), for example, would I put the login form? In the java 
example, the html goes into the src/main/resources/templates. Do I put the 
files in the same place for java as groovy? Who decides where the MVC templates 
are stored? Thank yousiegfried   

Reply via email to