I’m using jhipster 8.4.0 in an angular project
I want the application to provide the user entered during registration on the user registration screen as a parameter to an API that searches for the account by the user and found, returns the account activation status (true/false).
ignoring the flow, the problem is… logged into the application, the service works normally through swagger and returns what is expected, but through postman when I perform my tests, it only works if I provide a bearer token, but I need the api to be able to consumed by unauthenticated users and not just authenticated ones.
.authorizeHttpRequests(
authz ->
// prettier-ignore
authz
.requestMatchers(mvc.pattern("/account/activated/**")).permitAll()
.requestMatchers(mvc.pattern("/account/activated/{login}")).permitAll()
Likewise, in my AccountResource.java I inserted the @PermitAll annotation:
@PermitAll
@GetMapping("/account/activated/{login}")
public boolean getActivationStatusByLogin(@PathVariable String login) {
Optional<User> user = userRepository.findOneByLogin(login);
return user.map(User::isActivated).orElseThrow(() -> new AccountResourceException("User with login " + login + " not found"));
}
remembering that the postman get I perform through the url
http://localhost:8080/api/account/activated/string-do-login-consultado
It turns out that there is nothing else to do, I only receive the status 401 – Unauthorized.
Postman for example, if I add the bearer token, it works exactly the same as when I’m logged in and I test the api using the application’s swagger.
What else do I need to do to make this service public, I’ve already tested everything I know, so wise wizards of the dev world, help this grasshopper here, please.
JackmanBR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.