首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Hilla Spring Security

Hilla Spring Security
EN

Stack Overflow用户
提问于 2022-09-14 11:18:49
回答 1查看 42关注 0票数 0

你能帮我安装Hilla + Spring安全(LDAP)吗?我已经从https://hilla.dev/docs/getting-started创建了演示项目

代码语言:javascript
复制
npx @vaadin/cli init --hilla --auth hilla-with-auth

这个项目很简单,但是我想要LDAP auth。就像我的另一个没有Hilla的应用程序一样:

代码语言:javascript
复制
@Configuration
@EnableAutoConfiguration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
class WebSecurityConfig extends VaadinWebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception  {
    http
            .authorizeRequests()
            .antMatchers("/logout/**", "/logout-success", "/login/**", "/static/**", "/**.png").permitAll()
            .anyRequest()
            .authenticated()
            .and()
            .formLogin()
            .loginPage("/login")
            .defaultSuccessUrl("/grocery", true)
            .failureUrl("/login?error=true")
            .permitAll()
            .and()
            .logout()
            .logoutUrl("/logout")
            .logoutSuccessUrl("/login?logout=true")
            .invalidateHttpSession(true)
            .deleteCookies("JSESSIONID")
            .permitAll()
            .and()
            .exceptionHandling().accessDeniedPage("/403")
            .and()
            .httpBasic();
    http.addFilterAfter(new CsrfLoggerFilter(), CsrfFilter.class);
}

@Autowired
public void configureGlobal(AuthenticationManagerBuilder authBuilder) throws Exception {
    authBuilder
            .ldapAuthentication()
            .userSearchFilter(new ParseConfigFile().getConf("AuthenticationManagerBuilder.userSearchFilter"))
            .userSearchBase(new ParseConfigFile().getConf("AuthenticationManagerBuilder.userSearchBase"))
            .groupSearchBase(new ParseConfigFile().getConf("AuthenticationManagerBuilder.groupSearchBase"))
            .groupSearchFilter(new ParseConfigFile().getConf("AuthenticationManagerBuilder.groupSearchFilter"))
            .contextSource()
            .url(new ParseConfigFile().getConf("AuthenticationManagerBuilder.url"))
            .managerDn(new ParseConfigFile().getConf("AuthenticationManagerBuilder.managerDn"))
            .managerPassword(new ParseConfigFile().getConf("AuthenticationManagerBuilder.managerPassword"));
}
}

为了获得LDAP auth,我必须在配置文件中更改什么?

EN

回答 1

Stack Overflow用户

发布于 2022-09-14 11:42:29

LDAP使用不同的协议进行通信。因此,必须首先运行LDAP服务器,然后使用Security提供的内容使用Security进行身份验证。

spring引导文档有一个配置文件,与您可能需要的配置文件类似:Ldap Auth示例

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73715949

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档