Removing characters from usernames

Phil Mayers p.mayers at imperial.ac.uk
Thu Feb 1 02:27:51 CET 2007


Andrew Zirkel wrote:
> Is there a way to parse the input of a username and password before it 
> is passed to the back end database?  I'm doing mac address 
> authentication and some devices are passing the mac address with dashes, 
> where I need to have no separation between the octets.  I basically need 
> to strip out these dashes from the input.

Either the "hints" file or "attr_rewrite" can do this. E.g. for the former:

DEFAULT User-Name =~ "(..)-(..)-(..)-(..)-(..)-(..)"
         User-Name := `%{1}%{2}%{3}%{4}%{5}%{6}`

Or in attr_rewrite:

modules {
         attr_rewrite username-mac {
                 attribute = User-Name
                 searchin = packet
                 searchfor = "^(..)-(..)-(..)-(..)-(..)-(..)$"
                 replacewith = "%{1}%{2}%{3}%{4}%{5}%{6}"
                 max_matches = 1
         }

}

authorize {
   preprocess
   username-mac
   # rest of modues
}



More information about the Freeradius-Users mailing list