Radiator Server Documentation — v10.33.2

Lua script context API - User sub-context

Table of Contents
  • user
  • Fields
  • Methods
  • Example

user

User data retrieved from backend.

Fields

FieldTypeAccessDescription
usernamestring?read/writeUsername
passwordstring?write-onlyPassword (write to set, read returns nil)
backendstring?read/writeBackend name that fetched user
groupsstring[]?readUser's groups
rolesstring[]?readUser's roles

Methods

MethodParametersReturnsDescription
clear_groups()--Remove all groups
append_group(name)group name-Add a group
clear_roles()--Remove all roles
append_role(name)role name-Add a role

Example

local context, previous = ...

local user = context.user

if user.username then
    -- Add user to a group based on realm
    if context.aaa.identity and context.aaa.identity:match("@admin%.") then
        user:append_group("administrators")
        user:append_role("admin")
    end
end

return previous
Table of Contents
Navigation
  • @verification

  • aaa

  • backends

  • caches

  • captures

  • certificates

  • clients

  • conditions

  • dictionary

  • hmac-otp

  • include

  • init

  • ip-accept

  • license

  • logging

  • management

  • proxy-protocol

  • scripts

    • context

      • aaa

      • acct

      • auth

      • cache

      • cert

      • eap

      • eap_teap

      • eap_ttls

      • http

      • radius

      • radiusproxy

      • stats

      • tls

      • user

      • vars

  • servers

  • statistics

  • stats

  • template

  • ui