[RADIATOR] Add atttributes to request. How?

Pavel Krasotin krasotinpa at gmail.com
Wed Feb 8 15:15:45 UTC 2023


Hi All -

what is the best way to add attributes to request?
I would like to authenticate users from one file and add reply attributes
from another selecting them by custom attribute, ex. My-User-Group.

I've done this with PostAuthHook but I think it's ugly.

Here is my config.

radiator.cfg:
...
<AuthBy FILE>
    Identifier  L2TP-USERS
    Filename    %D/conf.d/l2tp-users
    PostAuthHook sub { \
        my ($req, $rep, $handled, $reason) = @_; \
        if (${$handled} == $main::ACCEPT && ${$req}->code() eq
'Access-Request') \
        {\
            my $my_group = ${$rep}->get_attr('My-User-Group'); \
            &main::log($main::LOG_DEBUG, "Group: " . $my_group); \
            if ($my_group) {\
                ${$req}-> add_attr('My-User-Group',$my_group); \
            } \
        } \
    };
</AuthBy>

<AuthBy FILE>
    AuthenticateAttribute My-User-Group
    Identifier  L2TP-PROFILE
    Filename    %D/conf.d/l2tp-profile
</AuthBy>

<AuthBy GROUP>
    Identifier  LOGINUSER
    AuthByPolicy ContinueUntilReject
    AuthBy      L2TP-USERS
    AuthBy      L2TP-PROFILE
</AuthBy>

<Handler Service-Type = Framed-User>
    AuthBy LOGINUSER
    ...
    StripFromReply My-User-Group
</Handler>

conf.d/l2tp-users:
user User-Password="password"
        My-User-Group="l2tp"

conf.d/l2tp-profile:
l2tp
        Service-Type = Framed-User,
        Framed-Protocol = PPP

--
Best wishes
Pavel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.open.com.au/pipermail/radiator/attachments/20230208/b1b3f0ff/attachment.html>


More information about the radiator mailing list