Example usage for org.springframework.security.config.annotation.web.builders HttpSecurity authorizeRequests

List of usage examples for org.springframework.security.config.annotation.web.builders HttpSecurity authorizeRequests

Introduction

In this page you can find the example usage for org.springframework.security.config.annotation.web.builders HttpSecurity authorizeRequests.

Prototype

public ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry authorizeRequests()
        throws Exception 

Source Link

Document

Allows restricting access based upon the HttpServletRequest using <h2>Example Configurations</h2> The most basic example is to configure all URLs to require the role "ROLE_USER".

Usage

From source file:com.create.application.configuration.WebSecurityConfiguration.java

@Override
protected void configure(final HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/**").authenticated().and().httpBasic().realmName("OAuth Server");
}

From source file:com.banco.config.SecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/HB/**").access("hasRole('USER')").antMatchers("/resources/**")
            .permitAll().and().formLogin().loginPage("/login").permitAll()
            // .usernameParameter("username").passwordParameter("password")
            .defaultSuccessUrl("/HB/index").and().logout().permitAll().and().csrf();
}

From source file:com.greglturnquist.payroll.SecurityConfiguration.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/built/**", "/main.css").permitAll().anyRequest().authenticated()
            .and().formLogin().defaultSuccessUrl("/", true).permitAll().and().httpBasic().and().csrf().disable()
            .logout().logoutSuccessUrl("/");
}

From source file:com.launchkey.example.springmvc.SecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/favicon.ico", "/callback", "/authorized", "/images/**").permitAll()
            .anyRequest().authenticated().and().formLogin().loginPage("/login").permitAll().and().logout()
            .permitAll().logoutSuccessHandler(logoutSuccessHandler).and().csrf()
            .ignoringAntMatchers("/callback", "/authorized");
}

From source file:com.pw.ism.WebSecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers(HttpMethod.POST, "/newmessage", "/addheartbeat", "/create/*")
            .permitAll().antMatchers("/", "/create", "/css/**", "/js/**", "/images/**").permitAll().anyRequest()
            .authenticated().and().csrf().ignoringAntMatchers("/newmessage", "/addheartbeat").and().formLogin()
            .loginPage("/login").permitAll().and().logout().permitAll();
}

From source file:com.vaadinspringtemplate.security.SecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {

    http.authorizeRequests().antMatchers("/maga").anonymous().antMatchers("/#!main").access("hasRole('user')")
            .antMatchers("/#!admin").access("hasRole('admin')").and().formLogin().loginPage("/")
            .loginProcessingUrl("/login").defaultSuccessUrl("/#!main").failureUrl("/error")
            .usernameParameter("username").passwordParameter("password").and().logout()
            .logoutSuccessUrl("/logout").and().exceptionHandling()
            .authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/main")).and().csrf().disable();
}

From source file:io.springoneplatform.SecurityConfiguration.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests()

            // Secure management endpoints
            .antMatchers("/info").authenticated()

            // But enable everything else
            .antMatchers("/*").permitAll()

            .and()/*from ww w  .  ja v a 2  s .  c  o m*/
            // Use a form login to access the secured bits
            .formLogin().permitAll();
}

From source file:org.test.skeleton.core.config.WebSecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {

    http.authorizeRequests().antMatchers("/", "/resources/**", "/signup", "/csrf").permitAll().anyRequest()
            .authenticated().and().formLogin().permitAll().and().httpBasic().and().logout().permitAll();
}

From source file:ca.unx.template.config.SpringSecurityConfiguration.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/admin/**").hasRole("ADMIN").anyRequest().permitAll();

    http.formLogin().and().httpBasic();/*www  .j a v  a 2 s  .c  o  m*/
}

From source file:org.hobsoft.contacts.server.security.SecurityConfig.java

/**
 * {@inheritDoc}//ww  w. jav  a2  s .  c o m
 */
@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/favicon.ico").permitAll().antMatchers("/webjars/**").permitAll()
            .anyRequest().authenticated().and()
            // TODO: enable CSRF
            .csrf().disable().formLogin().loginPage("/login").permitAll().and().logout().permitAll();
}