All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
rlm_couchbase.c File Reference

Integrate FreeRADIUS with the Couchbase document database. More...

#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/libradius.h>
#include <freeradius-devel/modules.h>
#include <freeradius-devel/rad_assert.h>
#include <libcouchbase/couchbase.h>
#include "../rlm_json/json.h"
#include "mod.h"
#include "couchbase.h"
+ Include dependency graph for rlm_couchbase.c:

Go to the source code of this file.

Functions

static rlm_rcode_t mod_accounting (void *instance, REQUEST *request)
 Write accounting data to Couchbase documents. More...
 
static rlm_rcode_t mod_authorize (void *instance, REQUEST *request)
 Handle authorization requests using Couchbase document data. More...
 
static rlm_rcode_t mod_checksimul (void *instance, REQUEST *request)
 Check if a given user is already logged in. More...
 
static int mod_detach (void *instance)
 Detach the module. More...
 
static int mod_instantiate (CONF_SECTION *conf, void *instance)
 Initialize the rlm_couchbase module. More...
 

Variables

static const CONF_PARSER client_config []
 Client Configuration. More...
 
static const CONF_PARSER module_config []
 Module Configuration. More...
 
module_t rlm_couchbase
 

Detailed Description

Integrate FreeRADIUS with the Couchbase document database.

Id:
2c940117f8fcf09a56948af614d2a021b82c0231
Author
Aaron Hurt ahurt.nosp@m.@anb.nosp@m.cs.co.nosp@m.m

Definition in file rlm_couchbase.c.

Function Documentation

static rlm_rcode_t mod_accounting ( void *  instance,
REQUEST request 
)
static

Write accounting data to Couchbase documents.

Handle accounting requests and store the associated data into JSON documents in couchbase mapping attribute names to JSON element names per the module configuration.

When an existing document already exists for the same accounting section the new attributes will be merged with the currently existing data. When conflicts arrise the new attribute value will replace or be added to the existing value.

Parameters
instanceThe module instance.
requestThe accounting request object.
Returns
Operation status (rlm_rcode_t).

Definition at line 273 of file rlm_couchbase.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static rlm_rcode_t mod_authorize ( void *  instance,
REQUEST request 
)
static

Handle authorization requests using Couchbase document data.

Attempt to fetch the document assocaited with the requested user by using the deterministic key defined in the configuration. When a valid document is found it will be parsed and the containing value pairs will be injected into the request.

Parameters
instanceThe module instance.
requestThe authorization request.
Returns
Operation status (rlm_rcode_t).

Definition at line 187 of file rlm_couchbase.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static rlm_rcode_t mod_checksimul ( void *  instance,
REQUEST request 
)
static

Check if a given user is already logged in.

Process accounting data to determine if a user is already logged in. Sets request->simul_count to the current session count for this user.

Check twice. If on the first pass the user exceeds his maximum number of logins, do a second pass and validate all logins by querying the terminal server.

Parameters
instanceThe module instance.
requestThe checksimul request object.
Returns
Operation status (rlm_rcode_t).

Definition at line 464 of file rlm_couchbase.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int mod_detach ( void *  instance)
static

Detach the module.

Detach the module instance and free any allocated resources.

Parameters
instanceThe module instance.
Returns
Returns 0 (success) in all conditions.

Definition at line 850 of file rlm_couchbase.c.

+ Here is the call graph for this function:

static int mod_instantiate ( CONF_SECTION conf,
void *  instance 
)
static

Initialize the rlm_couchbase module.

Intialize the module and create the initial Couchbase connection pool.

Parameters
confThe module configuration.
instanceThe module instance.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 82 of file rlm_couchbase.c.

+ Here is the call graph for this function:

Variable Documentation

const CONF_PARSER client_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("view", PW_TYPE_STRING, rlm_couchbase_t, client_view), .dflt = "_design/client/_view/by_name" },
}
#define CONF_PARSER_TERMINATOR
Definition: conffile.h:289
The main module instance.
Definition: mod.h:47
#define FR_CONF_OFFSET(_n, _t, _s, _f)
Definition: conffile.h:168
String of printable characters.
Definition: radius.h:33

Client Configuration.

Definition at line 43 of file rlm_couchbase.c.

const CONF_PARSER module_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("password", PW_TYPE_STRING, rlm_couchbase_t, password) },
{ FR_CONF_OFFSET("acct_key", PW_TYPE_TMPL, rlm_couchbase_t, acct_key), .dflt = "radacct_%{%{Acct-Unique-Session-Id}:-%{Acct-Session-Id}}", .quote = T_DOUBLE_QUOTED_STRING },
{ FR_CONF_OFFSET("doctype", PW_TYPE_STRING, rlm_couchbase_t, doctype), .dflt = "radacct" },
{ FR_CONF_OFFSET("expire", PW_TYPE_INTEGER, rlm_couchbase_t, expire), .dflt = 0 },
{ FR_CONF_OFFSET("user_key", PW_TYPE_TMPL, rlm_couchbase_t, user_key), .dflt = "raduser_%{md5:%{tolower:%{%{Stripped-User-Name}:-%{User-Name}}}}", .quote = T_DOUBLE_QUOTED_STRING },
{ FR_CONF_OFFSET("read_clients", PW_TYPE_BOOLEAN, rlm_couchbase_t, read_clients) },
{ FR_CONF_POINTER("client", PW_TYPE_SUBSECTION, NULL), .dflt = (void const *) client_config },
{ FR_CONF_OFFSET("check_simul", PW_TYPE_BOOLEAN, rlm_couchbase_t, check_simul) },
{ FR_CONF_OFFSET("simul_view", PW_TYPE_STRING, rlm_couchbase_t, simul_view), .dflt = "_design/acct/_view/by_user" },
{ FR_CONF_OFFSET("simul_vkey", PW_TYPE_TMPL, rlm_couchbase_t, simul_vkey), .dflt = "%{tolower:%{%{Stripped-User-Name}:-%{User-Name}}}", .quote = T_DOUBLE_QUOTED_STRING },
{ FR_CONF_OFFSET("verify_simul", PW_TYPE_BOOLEAN, rlm_couchbase_t, verify_simul) },
}
#define CONF_PARSER_TERMINATOR
Definition: conffile.h:289
#define PW_TYPE_SUBSECTION
Definition: conffile.h:188
The main module instance.
Definition: mod.h:47
A truth value.
Definition: radius.h:56
32 Bit unsigned integer.
Definition: radius.h:34
static const CONF_PARSER client_config[]
Client Configuration.
Definition: rlm_couchbase.c:43
#define FR_CONF_OFFSET(_n, _t, _s, _f)
Definition: conffile.h:168
#define PW_TYPE_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
Definition: conffile.h:200
String of printable characters.
Definition: radius.h:33
#define FR_CONF_POINTER(_n, _t, _p)
Definition: conffile.h:172
#define PW_TYPE_TMPL
CONF_PAIR should be parsed as a template.
Definition: conffile.h:208

Module Configuration.

Definition at line 51 of file rlm_couchbase.c.

module_t rlm_couchbase
Initial value:
= {
.magic = RLM_MODULE_INIT,
.name = "couchbase",
.inst_size = sizeof(rlm_couchbase_t),
.config = module_config,
.instantiate = mod_instantiate,
.detach = mod_detach,
.methods = {
},
}
static rlm_rcode_t mod_accounting(void *instance, REQUEST *request)
Write accounting data to Couchbase documents.
static rlm_rcode_t mod_authorize(void *instance, REQUEST *request)
Handle authorization requests using Couchbase document data.
#define RLM_TYPE_THREAD_SAFE
Module is threadsafe.
Definition: modules.h:75
#define RLM_MODULE_INIT
Definition: modules.h:86
struct rlm_couchbase_t rlm_couchbase_t
The main module instance.
static const CONF_PARSER module_config[]
Module Configuration.
Definition: rlm_couchbase.c:51
static int mod_instantiate(CONF_SECTION *conf, void *instance)
Initialize the rlm_couchbase module.
Definition: rlm_couchbase.c:82
static int mod_detach(void *instance)
Detach the module.
4 methods index for checksimul section.
Definition: modules.h:45
3 methods index for accounting section.
Definition: modules.h:44
static rlm_rcode_t mod_checksimul(void *instance, REQUEST *request)
Check if a given user is already logged in.
1 methods index for authorize section.
Definition: modules.h:42

Definition at line 864 of file rlm_couchbase.c.