2017-04-25 45 views
0

我目前在使用Spring.io教程。鏈接是Authenicating-ladpsecuring-webldapAuthentication與inMemoryAuthentication有什麼區別?

我可以看到,他們是非常相似,除了配置。

LDAP

@Override 
    public void configure(AuthenticationManagerBuilder auth) throws Exception { 
     auth 
      .ldapAuthentication() 
       .userDnPatterns("uid={0},ou=people") 
       .groupSearchBase("ou=groups") 
       .contextSource(contextSource()) 
       .passwordCompare() 
        .passwordEncoder(new LdapShaPasswordEncoder()) 
        .passwordAttribute("userPassword"); 
    } 

    @Bean 
    public DefaultSpringSecurityContextSource contextSource() { 
     return new DefaultSpringSecurityContextSource(Arrays.asList("ldap://localhost:8389/"), "dc=springframework,dc=org"); 
    } 

保護的Web

@Autowired 
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { 
     auth 
      .inMemoryAuthentication() 
       .withUser("user").password("password").roles("USER"); 
    } 

有什麼親和使用各的利弊?哪一個最適合最佳實踐?

+0

你擡頭看看「LDAP」和「內存中」是什麼意思? – OrangeDog

回答

0

內存中驗證是最簡單的形式,並且要求在代碼中指定所有用戶的憑據。除了最簡單的情況外,這是不切實際的。

LDAP身份驗證涉及對全球許多組織和企業中使用的訪問系統LDAP進行身份驗證。它相當靈活,因此更復雜。