Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Restrict POST request from a specific SlingAllMethodsServlet

priyadarshi_cts
Level 1
Level 1

Hi,

I have defined both doGet() and doPost() methods for SlingAllMethodsServlet as below

@Override

protected void doGet(SlingHttpServletRequest request,
SlingHttpServletResponse response) throws ServletException {

}

@Override
protected void doPost(SlingHttpServletRequest request,
SlingHttpServletResponse response) throws ServletException {

}

Why are both GET and POST requests in this servlet accessible from Postman even though sling.servlet.methods has been explicitly declared as GET  as shown below? 

@component(
service = { Servlet.class },
property = {
"sling.servlet.methods=" + HttpConstants.METHOD_GET,
"sling.servlet.paths="+ "/bin/sling/requestchecker",
},
)

1 Accepted Solution
aemmarc
Correct answer by
Employee
Employee

See : https://sling.apache.org/documentation/the-sling-engine/servlets.html

 

sling.servlet.methods is only applicable on registration of a servlet via sling.servlet.resourceTypes

 

your servlet example is registered on sling.servlet.paths

View solution in original post

1 Reply
aemmarc
Correct answer by
Employee
Employee

See : https://sling.apache.org/documentation/the-sling-engine/servlets.html

 

sling.servlet.methods is only applicable on registration of a servlet via sling.servlet.resourceTypes

 

your servlet example is registered on sling.servlet.paths

View solution in original post