[스프링(spring)]스프링 시큐리티(spring security) config설정하기

allnight5·2022년 12월 22일
0

스프링

목록 보기
17/62

참조사이트 1 영어임
참조사이트 2 예시나 .anyRequest().authenticated()에 대한 간단한 설명이 있다.

authorizeRequests()가 취소선이 되고
antMatchers가 오류가나온다.

        http.authorizeRequests()
                .antMatchers("/h2-console/**").permitAll()
                .antMatchers("/css/**").permitAll()
                .antMatchers("/js/**").permitAll()
                .antMatchers("/images/**").permitAll()
                .requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
                .anyRequest().authenticated();

아래와 같이 변경해줬다.

        http.authorizeHttpRequests(authorize -> authorize
                .requestMatchers("/h2-console/**").permitAll()
                .requestMatchers("/css/**").permitAll()
                .requestMatchers("/js/**").permitAll()
                .requestMatchers("/images/**").permitAll()
                .requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
                .anyRequest().authenticated()
        );

검색해보는데 영어만 나온다. 이제 영어를번역하면서 어떤것이 바뀌었는지 알아보자
보니까.. 이게 최신화 된것이다
authorizeRequests() ->authorizeHttpRequests()로 바꾸어줬다.

profile
공부기록하기

0개의 댓글