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:pl.ething.config.SecurityConfiguration.java

@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
    httpSecurity.authorizeRequests()
            .antMatchers("/", "/test", "/error", "/home", "/activation/**", "/thing/**", "/register",
                    "/public/**", "/registerUser", "/rememberPassword", "/isLogedUser", "/profil/**",
                    "/rememberme")
            .permitAll().anyRequest().authenticated().and().csrf().disable().formLogin().loginPage("/login")
            .defaultSuccessUrl("/", true).permitAll().and().logout().logoutUrl("/logout").permitAll();
}

From source file:showcase.WebSecurityConfiguration.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    // @formatter:off
    http.authorizeRequests().antMatchers("/**").hasRole("USER").and().httpBasic();
    // @formatter:on
}

From source file:fr.lepellerin.ecole.config.GestEcoleSecurityConfig.java

@Override
protected void configure(final HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/forgottenPassword").permitAll().antMatchers("/forgottenUsername")
            .permitAll().antMatchers("/assets/**").permitAll().antMatchers("/webjars/**").permitAll()
            .antMatchers("/cantine/**").access("hasRole('ROLE_FAMILLE')").antMatchers("/admin/**")
            .access("hasRole('ROLE_ADMIN')").antMatchers("/**").authenticated().and().formLogin()
            .loginPage("/login").defaultSuccessUrl("/", true).permitAll().and().logout().permitAll();

}

From source file:com.github.djabry.platform.vaadin.config.WebSecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests()
            //.antMatchers("/VAADIN/**", "/PUSH/**", "/UIDL/**", "/login", "/login/**", "/register", "/environment").permitAll()
            //.antMatchers("/**").fullyAuthenticated()
            .anyRequest().permitAll().and().csrf().disable().exceptionHandling()
            .authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/"))
            //.formLogin().defaultSuccessUrl("/").permitAll()
            .and()//from   w  w  w.j a va 2 s  . c om

            .logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout")).logoutSuccessUrl("/")
            .permitAll();
}

From source file:com.github.cherimojava.orchidae.config.cfgSecurity.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/picture").authenticated().anyRequest().permitAll().and().formLogin()
            .loginPage("/#/login").permitAll().loginProcessingUrl("/login.form");
}

From source file:com.javaetmoi.sample.config.SecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/signup", "/about").permitAll().antMatchers("/admin/**")
            .hasRole("ADMIN").anyRequest().authenticated() // 7
            .and().formLogin().loginPage("/login").permitAll();
}

From source file:se.omegapoint.facepalm.client.config.SecurityConfig.java

@Override
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
protected void configure(final HttpSecurity httpSecurity) throws Exception {
    httpSecurity.authorizeRequests().antMatchers("/fonts/**").permitAll().antMatchers("/register").permitAll()
            .anyRequest().authenticated().and().formLogin().loginPage("/login").permitAll().and().logout()
            .logoutRequestMatcher(new AntPathRequestMatcher("/logout")).permitAll().and().exceptionHandling()
            .accessDeniedPage("/access?error").and().headers().xssProtection().block(false)
            .xssProtectionEnabled(false).and() // Default setting for Spring Boot to activate XSS Protection (dont fix!)
            .and().csrf().disable(); // FIXME [dh] Enabling CSRF prevents file upload, must be fixed
}

From source file:me.bulat.jivr.webmin.config.SecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/admin/**").access("hasRole('ROLE_ADMIN')").antMatchers("/user/**")
            .access("hasAnyRole('ROLE_USER', 'ROLE_ADMIN')").and().formLogin().loginPage("/login")
            .defaultSuccessUrl("/login", false);

}

From source file:spring.SecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.csrf().disable();/*  ww w .j  a v  a  2  s.c o m*/
    http.authorizeRequests().antMatchers("/test/*").permitAll().antMatchers("/test").permitAll()
            .antMatchers("/reg").permitAll().antMatchers("/create").permitAll().anyRequest().authenticated()
            .and().formLogin().loginPage("/login").loginProcessingUrl("/login").defaultSuccessUrl("/")
            .permitAll().and().logout().permitAll();

}

From source file:com.example.ResourceConfig.java

@Override
public void configure(final HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/users/**")
            .access("#oauth2.hasScope(T(com.example.jpa.Scope).USER.asString())").antMatchers("/messages/**")
            .access("#oauth2.hasScope(T(com.example.jpa.Scope).MESSAGE.asString())")
            .antMatchers("/", "/lib/*", "/images/*", "/css/*", "/swagger-ui.js", "/swagger-ui.min.js",
                    "/api-docs", "/fonts/*", "/api-docs/*", "/api-docs/default/*", "/o2c.html", "index.html",
                    "/webjars/**", "/swagger-ui.html")
            .permitAll().anyRequest().authenticated();
}