java - Restrict which requests a ServletDispatcher processes -
can control requests specific dispatcherservlet
instances allowed issue? have defined 2 dispatchers, 1 service requests /public/public*
, private/private*
.
here dispatchers
@springbootapplication public class application extends springbootservletinitializer { public static void main(string[] args) { applicationcontext ctx = springapplication.run(application.class, args); } @override protected springapplicationbuilder configure( springapplicationbuilder application) { return application.sources(application.class); } @bean public dispatcherservlet dispatcherservletpublic() { return new dispatcherservlet(); } @bean public servletregistrationbean dispatcherservletpublicregistration() { servletregistrationbean registration = new servletregistrationbean(dispatcherservletpublic(), "/public/public*"); registration.setname(dispatcherservletautoconfiguration.default_dispatcher_servlet_registration_bean_name); return registration; } @bean public dispatcherservlet dispatcherservletprivate() { return new dispatcherservlet(); } @bean public servletregistrationbean dispatcherservletprivateregistration() { servletregistrationbean registration = new servletregistrationbean(dispatcherservletpublic(), "/private/private*"); registration.setname("private"); return registration; } }
the request mappings.
@restcontroller public class rmbonecontroller { @requestmapping("/public-data") public string publicdata() { return "here data: 42."; } @requestmapping("/private-data") public string privatedata() { return "here private data: 43."; } }
this doesn't work. getting whitelabel error page these 2 urls. not context root war /
.
http://localhost:8080/private/private-data http://localhost:8080/public/public-data
and few items confused about
i trying way because it's close servlet mappings - define servlet class respond givens urls.
<servlet-mapping> <servlet-name>publicservlet</servlet-name> <url-pattern>/public/*</url-pattern> </servlet-mapping> ... <servlet> <servlet-name>publicservlet</servlet-name> <servlet-class>foo.bar.publicservlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet>
- i thinking might way implement public , private areas - later put login filters on private dispatcher. see on page spring boot features - security assumption being way start authentication wrong. (i haven't had time yet go further it).
- soooo... possible restrict requests dispatcher can process.
- and why might done way?
Comments
Post a Comment