250x250
λ°˜μ‘ν˜•
Notice
Recent Posts
Recent Comments
Link
Β«   2024/12   Β»
일 μ›” ν™” 수 λͺ© 금 ν† 
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Archives
Today
Total
관리 메뉴

BEAT A SHOTGUN

[TROUBLESHOOTING] 403 ERROR ON USER RESISTRATION λ³Έλ¬Έ

TROUBLESHOOTING

[TROUBLESHOOTING] 403 ERROR ON USER RESISTRATION

thovy 2022. 10. 21. 16:47
728x90
λ°˜μ‘ν˜•
SMALL

ERROR ❌

πŸ€·β€β™‚οΈ?

USER λ₯Ό REGIST ν•˜λ €ν•˜λ©΄ 403 ERROR κ°€ 났닀.

μ•„λ‹ˆ 아직 아무것도 μ•ˆ λ§Œλ“€κ³  κΆŒν•œμ΄λΌλŠ” 게 μ—†λŠ” USER 에 403 ERROR???
ROLE 은 아직 μ•ˆ λ§Œλ“€μ—ˆλŠ”λ°?

πŸ™‹β€β™‚οΈ!!

μ•„ν•˜! λ‚˜λŠ” Security λ₯Ό μ‚¬μš©ν–ˆμ§€ !
μ•”ν˜Έν™”λ₯Ό μœ„ν•΄ BCryptPasswordEncoder 도 μ‚¬μš©ν–ˆμ§€!

SOLUTION βœ…

// SecurityConfig.java

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    ...


    @Override
❌  protected void configure(HttpSecurity http) throws Exception{
        http
                .authorizeHttpRequests()
                .antMatchers("/api/**")
                .permitAll();
    }

///////////////////////////////////////////////////////

    @Override
βœ…  protected void configure(HttpSecurity http) throws Exception{
        http
                .csrf().disable()
                .authorizeHttpRequests()
                .antMatchers("/api/**")
                .permitAll();
    }
}

.csrf().disable()

❗❗ CAUTION ❗❗
κ·Έλ ‡λ‹€κ³  λ¬΄μž‘μ • csrf λ₯Ό disable 둜 ν•˜λ©΄ μ•ˆ λœλ‹€.

λ‚˜λŠ” 혼자 μ›Ήμ‚¬μ΄νŠΈλ₯Ό λ§Œλ“€κ³  μžˆλŠ” κ±°κΈ° λ•Œλ¬Έμ— μ΄λ ‡κ²Œ μ‚¬μš©ν•˜μ§€λ§Œ, λ‚˜μ€‘μ— token 을 μ‚¬μš©ν•œλ‹€λ˜κ°€ λ‹€λ₯Έ λ°©λ²•μœΌλ‘œ csrf λ₯Ό μˆ˜μ •ν•΄μ•Ό ν•œλ‹€.

끝

γ…Žγ…Ž 이제 500 μ—λŸ¬λ‹€ γ…Žγ…Žγ…Žγ…Žγ…Žγ…Ž


πŸ˜‚

728x90
λ°˜μ‘ν˜•
LIST
Comments