diff --git a/src/main/java/io/quarkus/security/AuthenticationCompletionException.java b/src/main/java/io/quarkus/security/AuthenticationCompletionException.java new file mode 100644 index 0000000..7c0e64d --- /dev/null +++ b/src/main/java/io/quarkus/security/AuthenticationCompletionException.java @@ -0,0 +1,27 @@ +package io.quarkus.security; + +/** + * Exception indicating that a user authentication flow has failed and no challenge is required. + * + * For example, it can be used to avoid the redirect loops during an OpenId Connect authorization code flow + * after the user has already authenticated at the IDP site but a state parameter is not available after + * a redirect back to the Quarkus endpoint or if the code flow can not be completed for some other reasons. + */ +public class AuthenticationCompletionException extends RuntimeException { + + public AuthenticationCompletionException() { + + } + + public AuthenticationCompletionException(String errorMessage) { + this(errorMessage, null); + } + + public AuthenticationCompletionException(Throwable cause) { + this(null, cause); + } + + public AuthenticationCompletionException(String errorMessage, Throwable cause) { + super(errorMessage, cause); + } +} diff --git a/src/main/java/io/quarkus/security/AuthenticationRedirectException.java b/src/main/java/io/quarkus/security/AuthenticationRedirectException.java new file mode 100644 index 0000000..5a1e97b --- /dev/null +++ b/src/main/java/io/quarkus/security/AuthenticationRedirectException.java @@ -0,0 +1,30 @@ +package io.quarkus.security; + +/** + * Exception indicating that a redirect is required for the authentication flow to complete. + * + * For example, it can be used during an OpenId Connect authorization code flow to redirect + * the user to the original request URI which was used before the authorization code flow has started. + */ +public class AuthenticationRedirectException extends RuntimeException { + + final int code; + final String redirectUri; + + public AuthenticationRedirectException(String redirectUri) { + this(302, redirectUri); + } + + public AuthenticationRedirectException(int code, String redirectUri) { + this.code = code; + this.redirectUri = redirectUri; + } + + public int getCode() { + return this.code; + } + + public String getRedirectUri() { + return redirectUri; + } +}