Expand my Community achievements bar.

SOLVED

Mask servlet content or bin paths

Avatar

Level 4

Hi Team,

 

I have few path and resource based servlets.

 

For path based servlets, the path starts with localhost:4502/bin/test/v1/<identifier>. Is exposing /bin to the end user is a problem? If yes, why so since /bin/test/v1 is not a valid resource in AEM. In my case I want to mask this /bin/test/v1/<identifier> with a proxy. This proxy will be called in client side and I want to write rewrite rules for this proxy to execute actual servlet API i.e. /bin/test/v1/<identifier> is it best way 

 

For resource based servlets the path starts with localhost:4502/content/test/..../..selector.extension. I am also masking this content path with a proxy, client will call this proxy and I will redirect the request to actual servlet API. 

 

Is writing apache rewrites is better for this use case or is there any other approach like sling resource mapping?

 

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@Uppari_Ramesh In short, there is no problem we can use and expose /bin path and it will work fine. It's all about best practices for not to use /bin path.

View solution in original post

6 Replies

Avatar

Community Advisor

@Uppari_Ramesh : Is there a specific reason you want to register using the path?

There is another way using resourceType where you will not have to mask anything and it can be accessed using the page path with selectors, extension etc. Please refer:-

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

Please let me know if there is more to your requirement which I am missing.

thanks.

 

Avatar

Community Advisor

@Uppari_Ramesh 

 

PROS and CONS for servlet by path and resource type

https://sourcedcode.com/blog/aem/aem-sling-servlet-resource-type-for-post-get-code-example-code

Implementation
https://medium.com/@toimrank/aem-sling-servlet-ca9e5926a384#:~:text=Using%20Paths,use%20to%20registe....

Write apache rewrites if it is required, because of an overhead on dispatcher in terms of verifying rewrites rules every time and perform operation. On the other hand caching will also get impact and it will require separate development efforts.

Avatar

Administrator

@Uppari_Ramesh Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni

Avatar

Level 4

Hi @Imran__Khan @Kamal_Kishor ,

 

I would like to know, would there be any problem if we expose /bin path to end user?

 

Thanks!

Avatar

Correct answer by
Community Advisor

@Uppari_Ramesh In short, there is no problem we can use and expose /bin path and it will work fine. It's all about best practices for not to use /bin path.

Avatar

Employee Advisor

if you mount a servlet directly to a path, you cannot use the repository to implement access control. That's the reason why by default you should use the indirection via a resourcetype, because then you can apply authentication and authorization requirements to the servlet itself.

 

Why do you want/need to implement a rewrite or proxy for this servlet?