-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34812 from sberyozkin/oidc_javascript_checker
Allow to customize OIDC JavaRequest checks
- Loading branch information
Showing
9 changed files
with
124 additions
and
5 deletions.
There are no files selected for viewing
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
25 changes: 25 additions & 0 deletions
25
extensions/oidc/runtime/src/main/java/io/quarkus/oidc/JavaScriptRequestChecker.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.quarkus.oidc; | ||
|
||
import io.vertx.ext.web.RoutingContext; | ||
|
||
/** | ||
* JavaScriptRequestChecker can be used to check if the current request was made | ||
* by JavaScript running inside Single-page application (SPA). | ||
* <p/> | ||
* Some OpenId Connect providers may not support CORS in their authorization endpoints. | ||
* In such cases, SPA needs to avoid using JavaScript for running authorization code flow redirects | ||
* and instead delegate it to the browser. | ||
* <p/> | ||
* If this checker confirms it is a JavaScript request and if authentication challenge redirects are also disabled with | ||
* 'quarkus.oidc.authentication.java-script-auto-redirect=false' then an HTTP error status `499` will be reported allowing | ||
* SPA to intercept this error and repeat the last request causing the challenge with the browser API. | ||
*/ | ||
public interface JavaScriptRequestChecker { | ||
/** | ||
* Check if the current request was made by JavaScript | ||
* | ||
* @param context {@link RoutingContext} | ||
* @return true if the current request was made by JavaScript | ||
*/ | ||
boolean isJavaScriptRequest(RoutingContext context); | ||
} |
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
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
16 changes: 16 additions & 0 deletions
16
...sts/oidc-tenancy/src/main/java/io/quarkus/it/keycloak/CustomJavaScriptRequestChecker.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.quarkus.it.keycloak; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import io.quarkus.oidc.JavaScriptRequestChecker; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
@ApplicationScoped | ||
public class CustomJavaScriptRequestChecker implements JavaScriptRequestChecker { | ||
|
||
@Override | ||
public boolean isJavaScriptRequest(RoutingContext context) { | ||
return "true".equals(context.request().getHeader("HX-Request")); | ||
} | ||
|
||
} |
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