inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

스프링과 JPA 기반 웹 애플리케이션 개발

로그인 로그아웃

login 구현할때

2401

Dong Kyun Kang

작성한 질문수 5

2

import org.springframework.boot.autoconfigure.security.servlet.PathRequest;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
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()
                .mvcMatchers("/", "/login", "/sign-up",  "/check-email-token"
                        , "/email-login", "/check-email-login", "/login-link").permitAll()
                .mvcMatchers(HttpMethod.GET, "/profile/*").permitAll()
                .anyRequest().authenticated();

        http.formLogin()
                .loginPage("/login").permitAll();

        http.logout()
                .logoutSuccessUrl("/");
    }
...

강의 보면서 진행했을 땐 잘 작동했는데

이후 구현하면서 에러가 발생했습니다.

로그인 수행을 하면 로그인은 되지만 /error로 redirect 되어 화면에는 아래와 같은 에러가 뜹니다.

{"timestamp":"2020-04-15T14:28:16.449+0000","status":999,"error":"None","message":"No message available"}


spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration

구글링하면서 위 프로퍼티를 추가하여 해결했지만 /error을 요청하지 않았는데 왜 이런 현상이 발생하는지 이해가 되지 않습니다..

spring spring-boot JPA thymeleaf java

답변 3

10

LUA

저도 같은문제로 당황하고 있엇는데 정유성님이 이미지 때문이라고 하셔서 관련내용 찾아보다보니

로그인할 때 정적리소스를 찾지못하면 에러로 핸들링하는거 같아요 시큐리티 config 에서 웹 이그노잉에

.antMatchers("/favicon.ico", "/resources/**", "/error")

를 추가하니까 잘 되는거같습니다!

https://stackoverflow.com/questions/61029340/spring-security-redirects-to-page-with-status-code-999/61029341

1

foot

같은 문제였는데 fragments.html에 <img>에 작성한 이미지파일이 실제로 없어서 에러가 나네요

그런데 그냥 메인페이지 접속할때나 다른경우엔 오류가 안나는데 로그인으로 리다이렉트 하는 경우에만 오류가 나는 이유가 있나요?

1

백기선

스프링 부트 기본 설정에 따라 요청 처리시 에러가 발생하면 해당 에러 핸드러로 가게 되어있습니다. 어떤 요청이 제대로 처리가 안되는지 웹 브라우저에서 디버거를 열어서 요청을 확인해 보세요. 첫 페이지로 요청을 보내더라도 실제로는 한개만 보내지느게 아니라 이미지 리소스에 대한 요청도 보내지고 다양한 요청이 보내지는데 그 중에 어떤 요청이 실패하는지 찾아야 합니다.

Study 개설하는 로직에 대해서 궁금점이 있습니다.

0

55

1

앱 재시작 후 회원가입

0

103

1

app.host 관련 질문이 있습니다

0

97

1

강의 버전 정보

0

125

1

event, study 참조

0

220

2

비밀번호 변경 로직 질문있습니다.

0

135

1

프로필 수정 처리 merge 질문입니다.

0

108

1

회원가입 성공 후 redirect이동시 권한 질문

0

494

3

HtmlEmailService 개발하다 생긴 의문입니다

0

250

2

postgreSql 연결하여 JPA 를 통해 테이블 생성시 ZONE 테이블 생성에서 에러가 납니다

0

431

2

수업질문 [긴급] 로그인안되는 문제 말씀해주시는 부분 반영해서 최종 질문드립니다

0

261

2

[긴급-재업로드]수업질문 로그인 안 되는 문제

0

236

1

[긴급] 로그인해도 네비게이션 바가 안 바뀌고 있습니다!! 로그인이 안 됩니다 도와주세요

0

277

1

cropper 오류 문제로 질문드립니다..

0

288

2

authentication관련 질문...

0

495

2

모임참가 취소 할때 로직 질문

0

350

3

안녕하세요 기선님 질문이있습니다..

0

229

1

HTML코드 및 강의 중간자료들

0

679

3

springSecurity

0

523

2

버전 질문입니다.

0

302

1

부트스트랩, css

0

354

2

영속성 컨텍스트 질문

0

248

2

다시 강의를 보니 드는생각..

0

352

2

5:50에 나오는 HTML코드는 어디서 찾을 수 있나여?

0

313

1