Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Do not require auth on CORS preflights #283

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,27 @@ public class [anAdaptorInterface.javaClassNameForCredentialsFilter() /] implemen
* @return true - the resource is protected, otherwise false
*/
private boolean isProtectedResource(HttpServletRequest httpRequest) {
if (ignoreResourceProtection) {
return false;
}
String pathInfo = httpRequest.getPathInfo();

//'protectedResource' defines the basic set of requests that needs to be protected.
//You can override this defintion in the user protected code block below.
// Do not protect OSLC resources needed for initial discovery
boolean protectedResource = !pathInfo.startsWith("/rootservices") && !pathInfo.startsWith("/oauth");
// Do not protect CORS preflight requests
if (protectedResource) {
String method = httpRequest.getMethod();
if ("OPTIONS".equalsIgnoreCase(method)) {
protectedResource = false;
}
}
// Only for debugging!
if (ignoreResourceProtection) {
protectedResource = false;
}
// Here you can override or extend the checks
// [protected ('isProtectedResource')]
// [/protected]

return protectedResource;
}

Expand Down