Получение «Нет доступных сообщений» при вызове конечной точки REST - PullRequest
0 голосов
/ 19 января 2019

Я получаю следующую ошибку при вызове REST API.

{
    "timestamp": "2019-01-19T04:09:54.363+0000",
    "status": 404,
    "error": "Not Found",
    "message": "No message available",
    "path": "/createorganization"
}

Я новичок в JWT и только что добавил код авторизации и авторизации на основе учебника. У меня есть REST API «/ createorganization», который я разрешаю всем - в основном не требуется аутентификация Но я получаю вышеупомянутую ошибку, пытаясь достигнуть этого.

Вот подпись моего REST API ->

@GetMapping(path = "/createorganization")
public @ResponseBody CustomResponse createOrganization(String orgName, String, String email, String password) throws Exception {....

Вот мой класс WebSecurity с методом configure ->

@EnableWebSecurity
public class WebSecurity extends WebSecurityConfigurerAdapter {
    private UserDetailsServiceImpl userDetailsService;
    private BCryptPasswordEncoder bCryptPasswordEncoder;

public WebSecurity(UserDetailsServiceImpl userDetailsService, BCryptPasswordEncoder bCryptPasswordEncoder) {
        this.userDetailsService = userDetailsService;
        this.bCryptPasswordEncoder = bCryptPasswordEncoder;
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http.csrf().disable();
        http.authorizeRequests().antMatchers("/createorganization").permitAll().anyRequest().authenticated().and()
                .addFilter(new JWTAuthenticationFilter(authenticationManager()))
                .addFilter(new JWTAuthorizationFilter(authenticationManager()))
                // this disables session creation on Spring Security
                .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
    }

    @Override
    public void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder);
    }

    @Bean
    CorsConfigurationSource corsConfigurationSource() {
        final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        source.registerCorsConfiguration("/**", new CorsConfiguration().applyPermitDefaultValues());
        return source;
    }

А вот мой звонок из браузера Chrome -

http://localhost:8080/createorganization?orgName=abcd&email=john@gmail.com&password=complex

Я ожидал, что / createorganization будет вызвана, так как это allowAll () в методе configure ().

Большое спасибо за вашу помощь.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...