What I have: freeradius 2.1.10 on debian, configured to use a database.
How it works now:
There are many devices on the network and users, the users log on devices to configure them and so on. The users can log on to anything. For example some devices (ciscos) the user account on radius comes along with privileges (cisco-avpair
attribute) that restrict what that individual can and cannot do on cisco devices.
What I want freeradius to do in addition, for a specific special case: There's a special device that only select users should be able to authenticate into. Everyone else should be just denied access. (so, more strict than the cisco example above).
What I think I should be doing is first define my own attribute for example company-special-privilege
so that I can set that for some users in the database with a value of 0
or 1
. Then define some policy in policy.conf
.
What I'm asking:
Never done policies and I don't understand where they're applied in the rest of the freeradius config (where should I put my special_access
policy).
Also unsure how to formulate it but the following pseudocode should represent what I want:
special_access {
if (request to log in $special_device_ip) {
if ($username company-special-privilege) {
reject #
}
}
}
From the above I don't know how to get the device IP or the attribute that the user is set with. I'm not doing a == 1 on the attribute in the second condition in case the user doesn't have the attribute as I don't know what that would imply but any user that doesn't have 1 must be rejected.
You should put it in
raddb/policy.conf
inside thepolicy {}
stanza. Then they can be referenced (by their name) as you would a normal module, in authorize, authenticate, post-auth etc...Policies in FreeRADIUS are essentially macros, they're not functions, they don't take arguments.
Defining a special attribute to control policy decisions is fine, do it in
raddb/dictionary
unless you have an IANA number and want to spin your own custom dictionary. An easier way may just be to query SQL directly.I'm not sure what you want to do specifically, but here's an example that may help... Modify as necessary
Thanks to some info I found on http://linotp.org/doc/2.6/part-installation/integration/index.html you can use the following configuration if you use the nas table in the MySQL database. in the
nas
table you have IP ranges per device group, so if you device is in the specific IP range, the policy will be used:In the file
sites-enabled/default
you refer to the policy;and in the
policy.conf
you write your policy. This policy check first thenas
table for the restricted prefix and then checks if the user has sufficient rightsAnd of course in your
radusergroup
table where you're referring to in your SQL query you add an extra column where you allow specific users with extra rights.In this case I wrote the policy like this;
Cisco-AVPair := "shell:priv-lvl=15"
peter1
is just getting the normal rights.!= '1'
), it will get the right mentioned in the policy.update reply
you can usereject
to completely block access for this (peter
andpeter2
) users.it could get quiet complicated, but this works for me.