Skip to content

feat: Implemented security and permissions checks#57

Draft
jhuebert wants to merge 2 commits intomainfrom
feat/security
Draft

feat: Implemented security and permissions checks#57
jhuebert wants to merge 2 commits intomainfrom
feat/security

Conversation

@jhuebert
Copy link
Owner

No description provided.

} else {
authorizer = a -> a.anyRequest().permitAll();
}
return http.csrf(AbstractHttpConfigurer::disable)

Check failure

Code scanning / CodeQL

Disabled Spring CSRF protection High

CSRF vulnerability due to protection being disabled.

Copilot Autofix

AI 10 months ago

To fix the issue, CSRF protection should be enabled by default. Instead of disabling CSRF protection, the configuration should allow for proper CSRF token validation. If there are specific endpoints that do not require CSRF protection (e.g., APIs used by non-browser clients), those endpoints can be explicitly excluded from CSRF protection using Spring's csrf().ignoringRequestMatchers() method.

The changes will involve:

  1. Removing the http.csrf(AbstractHttpConfigurer::disable) line.
  2. Configuring CSRF protection properly, ensuring that it is enabled for browser-accessible endpoints.
  3. Optionally, excluding specific endpoints from CSRF protection if necessary.

Suggested changeset 1
src/main/java/org/huebert/iotfsdb/security/SecurityConfig.java

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/main/java/org/huebert/iotfsdb/security/SecurityConfig.java b/src/main/java/org/huebert/iotfsdb/security/SecurityConfig.java
--- a/src/main/java/org/huebert/iotfsdb/security/SecurityConfig.java
+++ b/src/main/java/org/huebert/iotfsdb/security/SecurityConfig.java
@@ -34,3 +34,3 @@
         }
-        return http.csrf(AbstractHttpConfigurer::disable)
+        return http.csrf(csrf -> csrf.ignoringRequestMatchers("/api/**")) // Enable CSRF protection, exclude API endpoints
                 .formLogin(Customizer.withDefaults())
EOF
@@ -34,3 +34,3 @@
}
return http.csrf(AbstractHttpConfigurer::disable)
return http.csrf(csrf -> csrf.ignoringRequestMatchers("/api/**")) // Enable CSRF protection, exclude API endpoints
.formLogin(Customizer.withDefaults())
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant