top.html에 로그인 링크를 만들어서 로그인을 해봤습니다
275
68 câu hỏi đã được viết
안녕하세요.
지금 개발환경은 스프링부트, 시큐리티 모두 최신 버전입니다.
permitAll()로 static resource를 허용하고 싶은데요. 설정을 분리하니까 login 하고 나서 css 파일이 화면에 나타납니다. 로그인 버튼은 top.html에 링크를 추가했습니다.

ignoring()을 쓰거나 설정을 통합하면 문제가 해결되긴 합니다.
http.authorizeHttpRequests(registry -> registry
.requestMatchers("/mypage").hasRole("USER")
.requestMatchers("/messages").hasRole("MANAGER")
.requestMatchers("/config").hasRole("ADMIN")
.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
.requestMatchers("/").permitAll()
.anyRequest().authenticated());하지만 저는 설정을 두 개로 유지하면서, permitAll()을 써도 문제가 없었으면 하는데, 제가 아는 선에서는 방법을 찾기 어려워 질문드리게 됐습니다.
@Order(0)
@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(registry -> registry
.requestMatchers("/mypage").hasRole("USER")
.requestMatchers("/messages").hasRole("MANAGER")
.requestMatchers("/config").hasRole("ADMIN")
.requestMatchers("/").permitAll()
.anyRequest().authenticated());
http.formLogin(Customizer.withDefaults());
http.logout(config -> config.logoutSuccessUrl("/"));
http.userDetailsService(userDetailsService);
return http.build();
}
@Order(1)
@Bean
SecurityFilterChain resource(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(registry -> registry
.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
.anyRequest().authenticated());
return http.build();
}감사합니다.
Câu trả lời 2
1
이 부분도 제가 직접 테스트 해 봐야 할 수 있을 것 같습니다.
전체 소스를 공유 부탁드립니다.
그리고 스프링 시큐리티 최신 버전에 관련된 질문은 경우에 따라서는 강의 범위를 넘어설 수 있기 때문에 정확한 답변들 드리기 어려운 점 양해 부탁드립니다.
0
넵! 강의 범위를 벗어난 점 알고 있습니다ㅠ도저히 이유를 모르겠어서 여쭙게 되었습니다..
브랜치 주소입니다!
https://github.com/literate-t/corespringsecurity_/tree/question/login-error
아래는 application.yml입니다!
application.yml
spring:
datasource:
url: jdbc:postgresql://localhost:5432/postgres
username: postgres
password: postgres
jpa:
hibernate:
ddl-auto: create
show-sql: true
properties:
hibernate:
format_sql: true
thymeleaf:
cache: false
devtools:
livereload:
enabled: true
restart:
enabled: true
1
음..
테스트를 해 보면 정상적으로 로그인되고 홈 화면으로 이동하고 있는데요...
css 파일은 나타나지 않는데요..
이게 저와는 다른 테스트 환경이 될 수도 있어서 동일하게 재현이 안되는군요
오류가 났을 때 어떤 상황인지 좀 더 자세한 설명이 가능할까요?

1
아아 정상 동작이 되시나요? 신기하군요..최초 질문글에 올렸던 사진처럼 로그인 이후에 css 파일 경로도 페이지가 리다이렉트 되어 버립니다..ㅋㅋ
실습 진행하면서 security filter chain을 여러 개 구성하면서도 문제가 없게끔 계속 다듬어 가고 있는데, 일단 정적 자원을 허용하는 코드는 따로 분리 안 하고 진행하고 있습니다!
시큐리티 공부 버전 질문
0
173
1
[해결 방법] MethodSecurityConfig.customMethodSecurityMetadataSource() 호출하지 않는 이슈
0
183
1
AbstractSecurityInterceptor.class.beforeInvocation()를 2번 실행하는 경우
0
172
1
강의 코드가 왜이렇게 뒤죽박죽인가요...
0
246
1
메인 페이지로 접속해도 login url로 리다이렉트가 되지 않습니다..
0
233
1
파라미터값이 넘어가지 않습니다 ....
0
372
1
security filterChain 설정 질문이 있습니다.
0
328
1
소스 부분 질문 드립니다.
0
206
2
섹션4 7번 강의 문제가 있는거 같네요.
0
342
2
파일이 수시로 이름이 바껴있네요 ㄷㄷ
0
302
1
HttpSessionSecurityContextRepository를 사용안하는 문제
0
553
2
error , exception 이 잘 안됩니다.
0
275
2
thymeleaf tag 질문합니다.
0
194
2
버전업하면서 deprecated된 것들이 너무많아요
0
476
1
spring security 패치 관련
0
435
1
모바일을 사용할때 토큰말고 세션
0
843
2
DB 연동한 인가 부분에 대한 질문입니다!
0
262
1
Ajax방식도 똑같이 Session방식을 사용하는건가요?
0
305
1
Config 파일 생성 시 질문이 있습니다.
0
223
1
강사님 몇일동안 구글 검색만 100개 했는데도 이유를 모르겠습니다..
1
427
2
403 에러 뜹니다.
0
809
2
login_proc의 존재에 대한 간략한 설명입니다
0
272
1
안녕하세요. DB에 저장될 때 이해 안 가는 값이 있어서 질문드립니다!
0
186
1
안녕하세요. 익명 객체와 세션 관련 궁금증입니다.
0
288
1

