使用带有freeradius的php password_hash密码

问题描述 投票:2回答:1

我有一个用户名和密码的数据库,使用password_hash加密,用于其他几个应用程序。

我想重用这些密码来使用freeradius对用户进行身份验证(用于wifi访问)。

我正在使用FreeRADIUS版本3.0.15,主机x86_64-pc-linux-gnu,于2017年7月28日06:41:27在Ubuntu 16.04服务器上构建FreeRADIUS版本3.0.15。客户是Unifi AP PRO。

我从默认安装开始,对配置的更改很少。出于测试目的,我在用户中添加了一个明文用户名和密码的用户。那个用户工作。

在网站启用/默认我添加在授权部分

update control {Auth-type := "/usr/bin/php -f /etc/freeradius/php/checkpasswd.php'%{User-Name}' '%{User-Password}'"}

在授权部分的最开始。 checkpasswd.php的相关部分是

//arguments ophalen
$username_radius = $argv[1];
$password_radius = $argv[2];

//wachtwoorden opzoeken in de databank
$query = $conn->prepare('SELECT passwordHash FROM gebruikers WHERE username = :username');
$query->bindParam(':username', $username_radius);
$query->execute();
$row_count = $query->rowCount();
if ($row_count != 1){
    echo 'Reject';
    }
    else {

//is de hash van het radiuswachtwoord gelijk aan de hash in de databank?
        $rs = $query->fetchAll();
        $passwordHash = $rs[0][0];
        if (password_verify($password_radius,$passwordHash)) {
            echo 'Accept';
        }
        else {
            echo 'Reject';
        }

(对不起荷兰语评论)基本上它表示在密码匹配时接受,在所有其他情况下表示拒绝。

我明白我需要使用TTLS / PAP才能看到密码。但密码永远不会在我的服务器上结束。我使用freeradius -X获得以下输出

(0) Received Access-Request Id 18 from 10.1.8.99:55827 to 192.168.2.32:1812 length 157
(0)   User-Name = "krog"
(0)   NAS-Identifier = "24a43cb081ea"
(0)   NAS-Port = 0
(0)   Called-Station-Id = "36-A4-3C-B1-81-EA:ritaexam"
(0)   Calling-Station-Id = "48-45-20-FB-4B-31"
(0)   Framed-MTU = 1400
(0)   NAS-Port-Type = Wireless-802.11
(0)   Connect-Info = "CONNECT 0Mbps 802.11b"
(0)   EAP-Message = 0x02660009016b726f67
(0)   Message-Authenticator = 0xfa1433a62a8b77ea794a62ac47f8320d
(0) # Executing section authorize from file /etc/freeradius/sites-enabled/default
(0)   authorize {
(0)     update control {
(0)       EXPAND /usr/bin/php -f /etc/freeradius/php/checkpasswd.php '%{User-Name}' '%{User-Password}'
(0)          --> /usr/bin/php -f /etc/freeradius/php/checkpasswd.php 'krog' ''
(0)     } # update control = fail
(0)   } # authorize = fail
(0) Using Post-Auth-Type Reject
(0) # Executing group from file /etc/freeradius/sites-enabled/default
(0)   Post-Auth-Type REJECT {
(0) attr_filter.access_reject: EXPAND %{User-Name}
(0) attr_filter.access_reject:    --> krog
(0) attr_filter.access_reject: Matched entry DEFAULT at line 11
(0)     [attr_filter.access_reject] = updated
(0) eap: Request was previously rejected, inserting EAP-Failure
(0) eap: Sending EAP Failure (code 4) ID 102 length 4
(0)     [eap] = updated
(0)     policy remove_reply_message_if_eap {
(0)       if (&reply:EAP-Message && &reply:Reply-Message) {
(0)       if (&reply:EAP-Message && &reply:Reply-Message)  -> FALSE
(0)       else {
(0)         [noop] = noop
(0)       } # else = noop
(0)     } # policy remove_reply_message_if_eap = noop
(0)   } # Post-Auth-Type REJECT = updated
(0) Delaying response for 1.000000 seconds
Waking up in 0.3 seconds.
Waking up in 0.6 seconds.
(0) Sending delayed response
(0) Sent Access-Reject Id 18 from 192.168.2.32:1812 to 10.1.8.99:55827 length 44
(0)   EAP-Message = 0x04660004
(0)   Message-Authenticator = 0x00000000000000000000000000000000

如您所见,用户密码在通信中无处可寻。我找到了各种帖子,提到这应该有效。我错过了明显的地方吗?

感谢您的见解。公园

php authentication freeradius
1个回答
0
投票

改变

update control {Auth-type := "/usr/bin/php -f /etc/freeradius/php/checkpasswd.php'%{User-Name}' '%{User-Password}'"}

update control {Auth-type := `/usr/bin/php -f /etc/freeradius/php/checkpasswd.php '%{User-Name}' '%{User-Password}'`}

为我修复了错误(使用`而不是“)

© www.soinside.com 2019 - 2024. All rights reserved.