sec:authentication="name"取不到值

本文讨论了在Spring Boot 2.1.4环境下,整合Spring Security和Thymeleaf时遇到的问题,即使用sec:authentication=name无法获取登录用户名。通过将thymeleaf-extras-springsecurity版本从4升级到5,问题得以解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

整合Springsecurity时需要获取登录的用户名使用sec:authentication="name"不能取到值

springboot版本:2.1.4
我的问题是thymeleaf-extras-springsecurity版本用的是4,改使用5没有问题

<dependency>
    <groupId>org.thymeleaf.extras</groupId>
    <artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
# wpa_supplicant -d -Dnl80211 -c/tmp/wpa.conf -iwlan0 wpa_supplicant v2.10 random: Trying to read entropy from /dev/random Successfully initialized wpa_supplicant Initializing interface 'wlan0' conf '/tmp/wpa.conf' driver 'nl80211' ctrl_interface 'N/A' bridge 'N/A' Configuration file '/tmp/wpa.conf' -> '/tmp/wpa.conf' Reading configuration file '/tmp/wpa.conf' Priority group 0 id=0 ssid='Xiaomi_6E67' nl80211: Supported cipher 00-0f-ac:1 nl80211: Supported cipher 00-0f-ac:5 nl80211: Supported cipher 00-0f-ac:2 nl80211: Supported cipher 00-0f-ac:4 nl80211: Supported cipher 00-0f-ac:6 nl80211: Using driver-based off-channel TX nl80211: key_mgmt=0xd0f enc=0x10f auth=0x7 flags=0x800d0c0 rrm_flags=0x0 probe_resp_offloads=0x0 max_stations=0 max_remain_on_chan=5000 max_scan_ssids=9 nl80211: interface wlan0 in phy phy0 nl80211: Set mode ifindex 2 iftype 2 (STATION) nl80211: Subscribe to mgmt frames with non-AP handle 0x4aef78 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0801 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=06 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0a07 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0a11 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=1101 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=1102 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0505 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0500 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=1301 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=1305 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=7e506f9a1a multicast=0 rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0 netlink: Operstate: ifindex=2 linkmode=1 (userspace-control), operstate=5 (IF_OPER_DORMANT) Add interface wlan0 to a new radio phy0 nl80211: Regulatory information - country=00 nl80211: 2402-2472 @ 40 MHz 20 mBm nl80211: 2457-2482 @ 20 MHz 20 mBm (no IR) nl80211: 2474-2494 @ 20 MHz 20 mBm (no OFDM) (no IR) nl80211: 5170-5250 @ 80 MHz 20 mBm (no IR) nl80211: 5250-5330 @ 80 MHz 20 mBm (DFS) (no IR) nl80211: 5490-5730 @ 160 MHz 20 mBm (DFS) (no IR) nl80211: 5735-5835 @ 80 MHz 20 mBm (no IR) nl80211: 57240-63720 @ 2160 MHz 0 mBm nl80211: Added 802.11b mode based on 802.11g information nl80211: Mode IEEE 802.11g: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484[DISABLED] nl80211: Mode IEEE 802.11b: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484[DISABLED] wlan0: Own MAC address: cc:b8:5e:f5:a6:86 wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=4 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wpa_driver_nl80211_set_key: ifindex=2 (wlan0) alg=0 addr=(nil) key_idx=5 set_tx=0 seq_len=0 key_len=0 key_flag=0x10 nl80211: DEL_KEY broadcast key wlan0: RSN: flushing PMKID list in the driver nl80211: Flush PMKIDs wlan0: Setting scan request: 0.100000 sec TDLS: TDLS operation not supported by driver TDLS: Driver uses internal link setup TDLS: Driver does not support TDLS channel switching wlan0: Added interface wlan0 wlan0: State: DISCONNECTED -> DISCONNECTED nl80211: Set wlan0 operstate 0->0 (DORMANT) netlink: Operstate: ifindex=2 linkmode=-1 (no change), operstate=5 (IF_OPER_DORMANT) nl80211: Skip set_supp_port(unauthorized) while not associated random: Got 20/20 bytes from /dev/random RTM_NEWLINK: ifi_index=2 ifname=wlan0 operstate=2 linkmode=1 ifi_family=0 ifi_flags=0x1003 ([UP]) wlan0: State: DISCONNECTED -> SCANNING Scan SSID - hexdump_ascii(len=11): 58 69 61 6f 6d 69 5f 36 45 36 37 Xiaomi_6E67 wlan0: Starting AP scan for wildcard SSID wlan0: Add radio work 'scan'@0x4b1718 wlan0: First radio work item in the queue - schedule start immediately wlan0: Starting radio work 'scan'@0x4b1718 after 0.000069 second wait wlan0: nl80211: scan request Scan requested (ret=0) - scan timeout 10 seconds nl80211: Drv Event 33 (NL80211_CMD_TRIGGER_SCAN) received for wlan0 wlan0: nl80211: Scan trigger wlan0: Event SCAN_STARTED (47) received wlan0: Own scan request started a scan in 0.000224 seconds RTM_NEWLINK: ifi_index=2 ifname=wlan0 wext ifi_family=0 ifi_flags=0x1003 ([UP]) nl80211: Drv Event 34 (NL80211_CMD_NEW_SCAN_RESULTS) received for wlan0 wlan0: nl80211: New scan results available nl80211: Scan probed for SSID 'Xiaomi_6E67' nl80211: Scan probed for SSID '' nl80211: Scan included frequencies: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 wlan0: Event SCAN_RESULTS (3) received wlan0: Scan completed in 1.758358 seconds nl80211: Received scan results (0 BSSes) wlan0: BSS: Start scan result update 1 BSS: last_scan_res_used=0/0 wlan0: New scan results available (own=1 ext=0) wlan0: Radio work 'scan'@0x4b1718 done in 2.200207 seconds wlan0: radio_work_free('scan'@0x4b1718): num_active_works --> 0 wlan0: No suitable network found wlan0: Setting scan request: 5.000000 sec Scan SSID - hexdump_ascii(len=11): 58 69 61 6f 6d 69 5f 36 45 36 37 Xiaomi_6E67 wlan0: Starting AP scan for wildcard SSID wlan0: Add radio work 'scan'@0x4b19d8 wlan0: First radio work item in the queue - schedule start immediately wlan0: Starting radio work 'scan'@0x4b19d8 after 0.000073 second wait wlan0: nl80211: scan request Scan requested (ret=0) - scan timeout 30 seconds nl80211: Drv Event 33 (NL80211_CMD_TRIGGER_SCAN) received for wlan0 wlan0: nl80211: Scan trigger wlan0: Event SCAN_STARTED (47) received wlan0: Own scan request started a scan in 0.000534 seconds RTM_NEWLINK: ifi_index=2 ifname=wlan0 wext ifi_family=0 ifi_flags=0x1003 ([UP]) nl80211: Drv Event 34 (NL80211_CMD_NEW_SCAN_RESULTS) received for wlan0 wlan0: nl80211: New scan results available nl80211: Scan probed for SSID 'Xiaomi_6E67' nl80211: Scan probed for SSID '' nl80211: Scan included frequencies: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 wlan0: Event SCAN_RESULTS (3) received wlan0: Scan completed in 1.760674 seconds nl80211: Received scan results (1 BSSes) wlan0: BSS: Start scan result update 2 wlan0: BSS: Add new id 0 BSSID cc:d8:43:81:b9:9e SSID 'Xiaomi_6E67' freq 2427 BSS: last_scan_res_used=1/32 wlan0: New scan results available (own=1 ext=0) wlan0: Radio work 'scan'@0x4b19d8 done in 2.204537 seconds wlan0: radio_work_free('scan'@0x4b19d8): num_active_works --> 0 wlan0: Selecting BSS from priority group 0 wlan0: 0: cc:d8:43:81:b9:9e ssid='Xiaomi_6E67' wpa_ie_len=0 rsn_ie_len=20 caps=0x1431 level=-59 freq=2427 wps wlan0: selected based on RSN IE wlan0: selected BSS cc:d8:43:81:b9:9e ssid='Xiaomi_6E67' wlan0: Considering connect request: reassociate: 0 selected: cc:d8:43:81:b9:9e bssid: 00:00:00:00:00:00 pending: 00:00:00:00:00:00 wpa_state: SCANNING ssid=0x4af4c0 current_ssid=(nil) wlan0: Request association with cc:d8:43:81:b9:9e TDLS: TDLS is allowed in the target BSS TDLS: TDLS channel switch allowed in the target BSS wlan0: No ongoing scan/p2p-scan found to abort wlan0: Add radio work 'connect'@0x4b3c38 wlan0: First radio work item in the queue - schedule start immediately wlan0: Starting radio work 'connect'@0x4b3c38 after 0.000096 second wait wlan0: WPA: clearing own WPA/RSN IE wlan0: RSN: clearing own RSNXE wlan0: RSN: using IEEE 802.11i/D9.0 wlan0: WPA: Selected cipher suites: group 16 pairwise 16 key_mgmt 2 proto 2 wlan0: WPA: Selected mgmt group cipher 32 wlan0: WPA: clearing AP WPA IE WPA: set AP RSN IE - hexdump(len=22): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00 wlan0: WPA: clearing AP RSNXE wlan0: WPA: AP group 0x10 network profile group 0x10; available group 0x10 wlan0: WPA: using GTK CCMP wlan0: WPA: AP pairwise 0x10 network profile pairwise 0x10; available pairwise 0x10 wlan0: WPA: using PTK CCMP wlan0: WPA: AP key_mgmt 0x2 network profile key_mgmt 0x2; available key_mgmt 0x2 wlan0: WPA: using KEY_MGMT WPA-PSK wlan0: WPA: AP mgmt_group_cipher 0x20 network profile mgmt_group_cipher 0x0; available mgmt_group_cipher 0x0 wlan0: WPA: not using MGMT group cipher WPA: Set own WPA IE default - hexdump(len=22): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00 RSN: Set own RSNXE default - hexdump(len=0): WPA: Set PMK based on external data - hexdump(len=32): [REMOVED] wlan0: Automatic auth_alg selection: 0x1 Added supported operating classes IE - hexdump(len=6): 3b 04 51 51 53 54 wlan0: Trying to associate with cc:d8:43:81:b9:9e (SSID='Xiaomi_6E67' freq=2427 MHz) wlan0: Cancelling scan request wlan0: State: SCANNING -> ASSOCIATING nl80211: Set wlan0 operstate 0->0 (DORMANT) netlink: Operstate: ifindex=2 linkmode=-1 (no change), operstate=5 (IF_OPER_DORMANT) nl80211: Skip set_supp_port(unauthorized) while not associated Limit connection to BSSID cc:d8:43:81:b9:9e freq=2427 MHz based on scan results (bssid_set=0 wps=0) nl80211: Set mode ifindex 2 iftype 2 (STATION) nl80211: Unsubscribe mgmt frames handle 0x88c267f1 (mode change) nl80211: Subscribe to mgmt frames with non-AP handle 0x4aef78 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0801 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=06 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0a07 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0a11 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=1101 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=1102 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0505 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=0500 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=1301 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=1305 multicast=0 nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x4aef78 match=7e506f9a1a multicast=0 nl80211: Connect (ifindex=2) * bssid=cc:d8:43:81:b9:9e * bssid_hint=cc:d8:43:81:b9:9e * freq=2427 * freq_hint=2427 * SSID=Xiaomi_6E67 * IEs - hexdump(len=41): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00 7f 0b 00 00 00 00 00 00 40 00 00 00 20 3b 04 51 51 53 54 * WPA Versions 0x2 * pairwise=0xfac04 * group=0xfac04 * akm=0xfac02 * Auth Type 0 [ 517.151623] RTL8723BS: rtw_set_802_11_connect(wlan0) fw_state = 0x00000008 nl80211: Connect request send successfully wlan0: Setting authentication timeout: 10 sec 0 usec
最新发布
06-07
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值