GraseHotspot / grase-www-portal

Grase WWW Portal (Main Package)
52 stars 20 forks source link

Computer Account / MAC address doesn't work #171

Open tnaefken opened 6 years ago

tnaefken commented 6 years ago

Last week I installed Grase Hotspot 3.8.0. When I tried to use the "Computer Account" functionality, it didn't work. In detail: I created a Computer Account by inputting the MAC address of my device - and, yes, following the hint I used "-" instead of ":" and uppercase letters in the hexadecimal values (why aren't they converted automatically to uppercase ?). When I connected my device to Grase Hotspot, I got the login page, but I exspected to get the Internet access without login.

After some research I found the user entry in the database table radius.radcheck: there the MAC address is the 'username'. But it is stored with LOWERCASE letters. After changing that into UPPERCASE letters (also in the tables radusercomment und radusergroup), it worked !

Further research showed me in DatabaseFunctions.class.php at line 916 the function createUser, and in line 926 (=first line of the function) there is a call

$username = mb_strtolower($username);

So, the letters in a MAC address (which had to be uppercase in the input field) become lowercase and are then stored in the database. My assumption is, that these lowercase-values won't match with the MAC address of a device, which has a uppercase representation in the software. My first idea was to change "mb_strtolower" into "mb_strtoupper" in line 926, but that would affect the normal usernames also, which are globally used in lowercase.

Next idea: I can let run a script which converts the MAC adresses in the database tables, but that's no solution, it's only a workaround.

I would like to convert the MAC address of the device just before "comparing" it with the database entry, but I'm not shure where to do it.

Have you any ideas or solutions ?

timwhite commented 6 years ago

Can you please collect some support data as stated at https://grasehotspot.org/support/collecting-support-information/ I've recently done some testing of MAC auth for a private project, and didn't have this problem. I'll do some more testing when I'm on my dev machine next.

tnaefken commented 6 years ago

Again I tried with a second device. By using the Web Admin Interface to create a computer account, the generated "UserName" entries in the "radius" databse became a lowercase MAC address - and using this for login didn't work. Then I converted the mac address manually in the tables "radius.radcheck" and "radius.radusergroup" to UPPERCASE MAC address, and - voil#a! - it worked !


I uploaded the requested data to https://paste.grasehotspot.org/view/7e219c32