Created
May 30, 2018 16:22
-
-
Save TiagoTi/ec09666bc86b04d4db154d8e9810de1f to your computer and use it in GitHub Desktop.
basic atutentication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.net.ti2.MarinaAbramovick.config; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | |
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | |
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | |
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | |
@Configuration | |
@EnableWebSecurity | |
public class SecurityConfig extends WebSecurityConfigurerAdapter{ | |
@Override | |
protected void configure(HttpSecurity http) throws Exception{ | |
http | |
.authorizeRequests() | |
.anyRequest() | |
.authenticated() | |
.and() | |
.httpBasic(); | |
} | |
@Autowired //Este é o cara que autoriza a requisição | |
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception{ | |
auth.inMemoryAuthentication() | |
.withUser("tiago").password("{noop}123321").roles("USER") | |
.and() | |
.withUser("quel").password("{noop}123123").roles("USER", "ADMIN"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment