Changing the login service URL in spring security

后端 未结 5 2217
攒了一身酷
攒了一身酷 2021-01-01 02:12

Hi I have implemented Spring security in my spring boot web application with JWT filters. But the default authentication is happening at url http://localhost:8080/logi

5条回答
  •  囚心锁ツ
    2021-01-01 02:48

    Modify "HttpSecurity", as follows, example:

    @Override
    protected void configure( HttpSecurity http ) throws Exception {
    http.cors().and().csrf().disable().authorizeRequests().antMatchers(HttpMethod.POST, "/rest/auth/**").permitAll()
            .antMatchers("/static/*").permitAll().antMatchers("/").permitAll()
            /* .anyRequest().authenticated() */
            .and()
                 .formLogin()
                 .loginPage("/login")
                 .loginProcessingUrl("/rest/auth/login")
                 .permitAll()
            .and()
                 .logout()
                 .permitAll();
            .and()
                 .addFilter(new JWTAuthenticationFilter(authenticationManager()))
                 .addFilter(new JWTAuthorizationFilter(authenticationManager()));
    }
    

提交回复
热议问题