-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a4d6bd
commit 3a497a0
Showing
3 changed files
with
53 additions
and
2 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
29 changes: 29 additions & 0 deletions
29
src/main/java/dev/sultanov/keycloak/multitenancy/resource/CorsResource.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,29 @@ | ||
package dev.sultanov.keycloak.multitenancy.resource; | ||
|
||
import jakarta.ws.rs.OPTIONS; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.core.Response; | ||
import org.keycloak.http.HttpRequest; | ||
import org.keycloak.models.KeycloakSession; | ||
import org.keycloak.services.resources.Cors; | ||
|
||
public class CorsResource { | ||
|
||
private final KeycloakSession session; | ||
private final HttpRequest request; | ||
|
||
public CorsResource(KeycloakSession session, HttpRequest request) { | ||
this.session = session; | ||
this.request = request; | ||
} | ||
|
||
public static final String[] METHODS = { | ||
"GET", "HEAD", "POST", "PUT", "DELETE", "PATCH", "OPTIONS" | ||
}; | ||
|
||
@OPTIONS | ||
@Path("{any:.*}") | ||
public Response preflight() { | ||
return Cors.add(request, Response.ok()).auth().allowedMethods(METHODS).preflight().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