인증에 필요한 Spring-boot 보안을 통과하는 방법
"root" 비밀번호를 입력했는데 계속 다시 나타납니다.어떻게 하면 이걸 억제하거나 없앨 수 있을까요?저는 스프링 부츠와 스프링 보안을 사용하고 있습니다.
application.properties
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/springbootpractice
spring.datasource.username=root
spring.jpa.database = MYSQL
spring.jpa.show-sql = true
# Hibernate
hibernate.dialect: org.hibernate.dialect.MySQL5Dialect
hibernate.show_sql: true
hibernate.hbm2ddl.auto: update
entitymanager.packagesToScan: /
나는 그것이 중요하다면 intelij 14를 사용하고 있습니다.
----업데이트 1-----
@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/index").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/index")
.permitAll()
.and()
.logout()
.permitAll();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/index").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/index")
.permitAll()
.and()
.logout()
.permitAll();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
}
}
이 클래스는 다른 모든 패키지의 상위 패키지에 있어야 합니다.WebSecurityConfig또한application.properties집합:
security.basic.enabled=false
ACV의 응답은 다음을 추가하여 인증을 완전히 해제하는 가장 쉬운 방법일 것입니다.security.basic.enabled=false일반적으로 다음 위치에 있는 application.properties 파일에src/main/resources폴더를 누릅니다.
아니면 그냥 비밀번호를 입력하세요 :)
기본 암호 사용
봄 응용 프로그램을 실행할 때, 보통 사람들이 읽지 않는 많은 양의 벌목이 인쇄됩니다.비밀번호는 실제로 생성되어 시작 시 화면에 출력됩니다.그리고 사용자 이름은 단순합니다.user브라우저를 사용하여 테스트하는 경우 한 번만 입력하고 캐시하면 되므로 매번 인증하지 않고 안전하게 로그인해야 합니다.(그러나 앱을 다시 시작할 때마다 새 암호가 생성됩니다.)
암호 사용자 지정
사용자 이름과 암호를 사용자 지정하려면 application.properties에 다음 속성을 추가합니다.
security.user.name=myuser
security.user.password=mypassword
사용자 자신의 사용자 이름과 암호를 사용하면 다음과 같습니다.
참조:
이 스프링 부팅 보안 메커니즘을 무시할 수 있습니다.아래의 예를 참조하십시오.
@SpringBootApplication
@EnableAutoConfiguration(exclude = {SecurityAutoConfiguration.class})
public class SampleSpringBootApplication {
public static void main(String[] args) {
SpringApplication.run(SampleSpringBootApplication.class, args);
}
}
Spring Security가 클래스 경로에 있는 경우 Spring Boot은 기본적으로 기본 인증으로 모든 페이지를 보호합니다.그것이 당신이 사용자 ID와 비밀번호를 묻는 이유입니다.
보안을 구성해야 합니다.그렇게 하기 위해, 일반적으로 사람들은 확장할 것입니다.WebSecurityConfigurerAdapter다음과 같이:
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/home").permitAll()
.anyRequest().authenticated()
.and()
...
여기 문제가 있었습니다.
.loginPage("/index")에서 로그인 페이지가 인덱스에 있다고 했지만, 봄의 기본 로그인 페이지를 사용하려고 했습니다.
보안 패키지를 데모 패키지(기본 패키지) 안으로 이동해야 했습니다.@Sanjay가 제안해 주셔서 감사합니다.@ComponentScan을 사용하려고 했지만 작동하지 않았습니다.
언급URL : https://stackoverflow.com/questions/31891344/how-to-get-past-the-authentication-required-spring-boot-security
'programing' 카테고리의 다른 글
| Mac에서 MongoDB 나침반 실행 (0) | 2023.06.21 |
|---|---|
| Git index.lock File은 커밋하려고 할 때 존재하지만 파일을 삭제할 수 없습니다. (0) | 2023.06.21 |
| R에서 라텍스 테이블을 만드는 도구 (0) | 2023.06.21 |
| git 특정 분기로 푸시 (0) | 2023.06.21 |
| ORA-02049 문제 해결 및 Oracle 일반 잠금 문제 해결 방법 (0) | 2023.06.21 |



