Restrict POST request from a specific SlingAllMethodsServlet

Avatar

Avatar
Validate 1
Level 1
priyadarshi_cts
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
priyadarshi_cts
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
priyadarshi_cts
Level 1

21-04-2020

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",
},
)

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Ignite 1
Employee
aemmarc
Employee

Likes

184 likes

Total Posts

243 posts

Correct reply

92 solutions
Top badges earned
Ignite 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Ignite 1
Employee
aemmarc
Employee

Likes

184 likes

Total Posts

243 posts

Correct reply

92 solutions
Top badges earned
Ignite 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
aemmarc
Employee

21-04-2020

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

Answers (0)