How to set custom realm in embedded tomcat server? I am using Spring Boot.

只愿长相守 提交于 2019-12-11 02:28:43

问题


How to set custom realm for the embedded tomcat? i am using SpringBoot however dont see a way to add custom realm via Embeddedservletcontainercustomizer.


回答1:


Looks like you should define this bean:

@Bean
public TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory() {
    TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
    factory.addContextCustomizers(new TomcatContextCustomizer() {
        @Override
        public void customize(Context context) {
            context.setRealm(new CombinedRealm());
        }
    });
    return factory;
}

And provide the desired Realm implementation.



来源:https://stackoverflow.com/questions/24429315/how-to-set-custom-realm-in-embedded-tomcat-server-i-am-using-spring-boot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!