-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add useful information to the authentication error
- Loading branch information
1 parent
4b5e37d
commit 7402dfc
Showing
3 changed files
with
27 additions
and
7 deletions.
There are no files selected for viewing
19 changes: 15 additions & 4 deletions
19
app/src/main/java/io/apicurio/registry/rest/AuthenticationFailedExceptionMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
package io.apicurio.registry.rest; | ||
|
||
import io.quarkus.security.AuthenticationFailedException; | ||
import io.quarkus.security.UnauthorizedException; | ||
import jakarta.annotation.Priority; | ||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.Priorities; | ||
import jakarta.ws.rs.core.Response; | ||
import jakarta.ws.rs.ext.ExceptionMapper; | ||
import jakarta.ws.rs.ext.Provider; | ||
|
||
@Provider | ||
@Priority(Priorities.AUTHENTICATION) | ||
public class AuthenticationFailedExceptionMapper implements ExceptionMapper<UnauthorizedException> { | ||
|
||
@Inject | ||
RegistryExceptionMapper exceptionMapperService; | ||
|
||
public class AuthenticationFailedExceptionMapper implements ExceptionMapper<AuthenticationFailedException> { | ||
@Override | ||
public Response toResponse(AuthenticationFailedException exception) { | ||
return Response.status(401).build(); | ||
public Response toResponse(UnauthorizedException exception) { | ||
Response errorHttpResponse = exceptionMapperService.toResponse(exception); | ||
return Response.status(401).entity(errorHttpResponse).build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters