第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

LDAP:在身份驗(yàn)證事件期間獲取自定義值

LDAP:在身份驗(yàn)證事件期間獲取自定義值

眼眸繁星 2022-12-15 16:07:36
我讓 Springboot 成功地對(duì) LDAP 進(jìn)行了身份驗(yàn)證并向視圖添加了一個(gè)CustomUserDetails模型。在身份驗(yàn)證活動(dòng)期間,我還想帶回其他詳細(xì)信息,如電子郵件、電話和城市。根據(jù)this SO answer,這是可能的,我認(rèn)為這也解決了這個(gè)問題。盡管閱讀了這兩個(gè)答案,但我仍然不確定如何繼續(xù)執(zhí)行此操作 - 特別是關(guān)于第二個(gè)答案的步驟 2 和 3 如何關(guān)聯(lián),以及電子郵件、城市和電話等詳細(xì)信息映射到哪里?我的安全等級(jí):安全@SpringBootApplicationpublic class ApplicationSecurity extends WebSecurityConfigurerAdapter {@Autowiredprivate UserDetailsService userDetailsService;@Overridepublic void configure(HttpSecurity http) throws Exception {    http            .authorizeRequests()                .anyRequest().fullyAuthenticated()                .and()            .formLogin()                .defaultSuccessUrl("/newExhibit");}@Overridepublic void configure(AuthenticationManagerBuilder auth) throws Exception {    auth            .userDetailsService(userDetailsService)            .and()            .ldapAuthentication()            .userDnPatterns("uid={0},ou=people")            .groupSearchBase("ou=groups")            .contextSource()            .url("ldap://localhost:8389/dc=springframework,dc=org")            .and()            .passwordCompare()            .passwordEncoder(passwordEncoder())            .passwordAttribute("userPassword");}我的用戶對(duì)象來自 test-server.ldifdn: uid=abc123,ou=people,dc=springframework,dc=orgobjectclass: topobjectclass: personobjectclass: organizationalPersonobjectclass: inetOrgPersoncn: Tom Smithsn: Smithuid: abc123userPassword: passmail: tom@contoso.commobile: +212 307 12345st: CA
查看完整描述

1 回答

?
月關(guān)寶盒

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超5個(gè)贊

查看您的 LDIF 文件,您似乎正在嘗試獲取定義為inetOrgPerson的一部分的屬性。Spring Security 為這個(gè)InetOrgPersonContextMapper. 這會(huì)將定義的屬性映射到InetOrgPerson,這將根據(jù)UserDetails需要進(jìn)行操作。

要配置您只需要?jiǎng)?chuàng)建一個(gè)新實(shí)例并將其連接到您的配置。

@SpringBootApplication

public class ApplicationSecurity extends WebSecurityConfigurerAdapter {



@Override

public void configure(AuthenticationManagerBuilder auth) throws Exception {

    auth

      .ldapAuthentication()

        .userDnPatterns("uid={0},ou=people")

        .groupSearchBase("ou=groups")

        .contextSource()

        .url("ldap://localhost:8389/dc=springframework,dc=org")

        .and()

        .userDetailsContextMapper(new InetOrgPersonContextMapper())

        .passwordCompare()

        .passwordEncoder(passwordEncoder())

        .passwordAttribute("userPassword");

}

這將相應(yīng)地映射屬性。當(dāng)您使用 LDAP 時(shí),您不需要UserDetailsService注入,因?yàn)樗鼤?huì)自動(dòng)配置LdapUserDetailsService底層。


查看完整回答
反對(duì) 回復(fù) 2022-12-15
  • 1 回答
  • 0 關(guān)注
  • 124 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)