How to enable POST, PUT AND DELETE methods in spring security
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
In Spring Security, POST, PUT, and DELETE are not usually “disabled” in a global sense. The real issue is that state-changing requests are often blocked by security rules, most commonly authorization rules or CSRF protection, so enabling them means configuring the security chain correctly for the kind of application you are building.
What Usually Blocks These Methods
When developers say “GET works but POST, PUT, and DELETE do not,” the cause is usually one of these:
- the request is not authorized for that path or method
- CSRF protection rejects the request
- CORS preflight is not configured for browser clients
So the fix is not just to “allow methods.” It is to match the HTTP method, path, and authentication model correctly.
Authorizing by HTTP Method
In modern Spring Security, use a SecurityFilterChain bean and method-specific request matchers.
This does not disable any method. It defines who may use each method on a given route.
CSRF Is the Common Surprise
By default, Spring Security protects browser-based state-changing requests with CSRF checks. That means:
- '
GETusually works' - '
POST,PUT, andDELETEmay fail with403'
If you are building a stateless REST API for non-browser clients and using tokens instead of session cookies, it is common to disable CSRF:
Do this only when it matches your authentication model. If you are using browser sessions and cookies, disabling CSRF casually is usually the wrong move.
CORS for Browser Clients
If the client is a browser app hosted on another origin, the problem may be CORS rather than Spring Security method authorization. In that case, add CORS support explicitly.
Then enable it in the security chain with http.cors(...).
A Full REST-Style Example
In this style, authenticated clients can use the protected API routes with all needed HTTP methods, assuming the controller mappings exist.
Common Pitfalls
One common mistake is blaming Spring Security method support when the real failure is CSRF. A 403 on POST with a working GET often points there first.
Another issue is allowing the method in authorization rules but forgetting browser CORS configuration, which makes the request fail before it reaches the controller.
A third pitfall is disabling CSRF without understanding whether the application still uses cookie-based browser sessions.
Summary
- '
POST,PUT, andDELETEare usually blocked by security rules, not globally disabled.' - Use method-specific request matchers to authorize those methods cleanly.
- For stateless APIs, disabling CSRF is common; for session-based browser apps, be more careful.
- Configure CORS when browser clients call the API from another origin.
- Check authorization, CSRF, and CORS before assuming the HTTP method itself is the problem.
Related reading
- How To Estimate the total time to complete the request In UDP and TCP ( Distributed Systems)
- How to explicitely define an Endpoint of an Kubernetes Service
- How to expose a Kubernetes service on a specific Nodeport?
- How to expose Kubernetes DNS externally
- How to encrypt String in Java
- How to exempt a directory when using readOnlyRootFilesystem in kubernetes?
- How to enable Scheduled jobs by profile in spring?
- How to ensure order of processing in Java 8 streams?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.