Spring Boot security

holman khan

Well-known member
  • Oct 19, 2021
    846
    563
    93
    Machan spring boot waldi spring security /login ekata controller ekak liyanne nathuwa puluwan da wada krana widiyata hadanna , meke JWT filter ehemath thiyanawa
     
    • Like
    Reactions: kinkon

    priyanka_hdp

    Well-known member
  • Sep 9, 2006
    2,635
    1,671
    113
    Stockholm
    Machan spring boot waldi spring security /login ekata controller ekak liyanne nathuwa puluwan da wada krana widiyata hadanna , meke JWT filter ehemath thiyanawa
    Interesting.. refer to the class in your source which extends WebSecurityConfigurerAdapter
    It has all the configurations machan. it could be handled by controller or without controller

    JWT uses for authorization not authentication

    Java:
    @Override
    protected void configure(HttpSecurity httpSecurity) throws Exception {
        httpSecurity.cors().and().csrf().disable()
                .authorizeRequests().
                .anyRequest().authenticated()
                and().
                exceptionHandling()
                    .authenticationEntryPoint(jwtAuthenticationEntryPoint)
                        .and()
                            .sessionManagement()
                                .sessionCreationPolicy(SessionCreationPolicy.STATELESS);
        httpSecurity.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class);
    }