The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Functions | Variables
rlm_couchbase.c File Reference

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

#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/map.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/radius/defs.h>
#include <freeradius-devel/json/base.h>
#include "mod.h"
#include "couchbase.h"
+ Include dependency graph for rlm_couchbase.c:

Go to the source code of this file.

Macros

#define LOG_PREFIX   "couchbase - "
 

Functions

static unlang_action_t mod_accounting (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 Write accounting data to Couchbase documents. More...
 
static unlang_action_t mod_authorize (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 Handle authorization requests using Couchbase document data. More...
 
static int mod_detach (module_detach_ctx_t const *mctx)
 Detach the module. More...
 
static int mod_instantiate (module_inst_ctx_t const *mctx)
 Initialize the rlm_couchbase module. More...
 
static int mod_load (void)
 

Variables

fr_dict_attr_t const * attr_acct_session_time
 
fr_dict_attr_t const * attr_acct_status_type
 
fr_dict_attr_t const * attr_event_timestamp
 
static const conf_parser_t client_config []
 Client Configuration. More...
 
static fr_dict_t const * dict_radius
 
static const conf_parser_t module_config []
 Module Configuration. More...
 
module_rlm_t rlm_couchbase
 
fr_dict_autoload_t rlm_couchbase_dict []
 
fr_dict_attr_autoload_t rlm_couchbase_dict_attr []
 

Detailed Description

Integrate FreeRADIUS with the Couchbase document database.

Id
e2008e764a8d28c48a3944d7a4604149d02856e9
Author
Aaron Hurt (ahurt.nosp@m.@anb.nosp@m.cs.co.nosp@m.m)

Definition in file rlm_couchbase.c.

Macro Definition Documentation

◆ LOG_PREFIX

#define LOG_PREFIX   "couchbase - "

Definition at line 29 of file rlm_couchbase.c.

Function Documentation

◆ mod_accounting()

static unlang_action_t mod_accounting ( rlm_rcode_t p_result,
module_ctx_t const *  mctx,
request_t 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
[out]p_resultResult of calling the module.
mctxmodule calling context.
requestThe accounting request object.

Definition at line 233 of file rlm_couchbase.c.

+ Here is the call graph for this function:

◆ mod_authorize()

static unlang_action_t mod_authorize ( rlm_rcode_t p_result,
module_ctx_t const *  mctx,
request_t request 
)
static

Handle authorization requests using Couchbase document data.

Attempt to fetch the document associated 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
[out]p_resultOperation status (rlm_rcode_t).
[in]mctxmodule calling context.
[in]requestThe authorization request.

Definition at line 99 of file rlm_couchbase.c.

+ Here is the call graph for this function:

◆ mod_detach()

static int mod_detach ( module_detach_ctx_t const *  mctx)
static

Detach the module.

Detach the module instance and free any allocated resources.

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

Definition at line 424 of file rlm_couchbase.c.

+ Here is the call graph for this function:

◆ mod_instantiate()

static int mod_instantiate ( module_inst_ctx_t const *  mctx)
static

Initialize the rlm_couchbase module.

Initialize the module and create the initial Couchbase connection pool.

Parameters
mctxThe module instance.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 444 of file rlm_couchbase.c.

+ Here is the call graph for this function:

◆ mod_load()

static int mod_load ( void  )
static

Definition at line 537 of file rlm_couchbase.c.

+ Here is the call graph for this function:

Variable Documentation

◆ attr_acct_session_time

fr_dict_attr_t const* attr_acct_session_time

Definition at line 77 of file rlm_couchbase.c.

◆ attr_acct_status_type

fr_dict_attr_t const* attr_acct_status_type

Definition at line 76 of file rlm_couchbase.c.

◆ attr_event_timestamp

fr_dict_attr_t const* attr_event_timestamp

Definition at line 78 of file rlm_couchbase.c.

◆ client_config

const conf_parser_t client_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("view", rlm_couchbase_t, client_view), .dflt = "_design/client/_view/by_name" },
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:626
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:268
The main module instance.
Definition: mod.h:44

Client Configuration.

Definition at line 44 of file rlm_couchbase.c.

◆ dict_radius

fr_dict_t const* dict_radius
static

Definition at line 68 of file rlm_couchbase.c.

◆ module_config

const conf_parser_t module_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("password", rlm_couchbase_t, password) },
{ FR_CONF_OFFSET("acct_key", rlm_couchbase_t, acct_key), .dflt = "radacct_%{%{Acct-Unique-Session-Id} || %{Acct-Session-Id}}", .quote = T_DOUBLE_QUOTED_STRING },
{ FR_CONF_OFFSET("doctype", rlm_couchbase_t, doctype), .dflt = "radacct" },
{ FR_CONF_OFFSET("expire", rlm_couchbase_t, expire), .dflt = 0 },
{ FR_CONF_OFFSET("user_key", rlm_couchbase_t, user_key), .dflt = "raduser_%md5(%tolower(%{Stripped-User-Name} || %{User-Name}))", .quote = T_DOUBLE_QUOTED_STRING },
{ FR_CONF_OFFSET("read_clients", rlm_couchbase_t, read_clients) },
{ FR_CONF_POINTER("client", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) client_config },
}
#define FR_CONF_POINTER(_name, _type, _flags, _res_p)
conf_parser_t which parses a single CONF_PAIR producing a single global result
Definition: cf_parse.h:310
#define FR_CONF_OFFSET_FLAGS(_name, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:256
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
Definition: cf_parse.h:406
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition: cf_parse.h:400
static const conf_parser_t client_config[]
Client Configuration.
Definition: rlm_couchbase.c:44
username
Definition: rlm_securid.c:420
@ T_DOUBLE_QUOTED_STRING
Definition: token.h:121

Module Configuration.

Definition at line 52 of file rlm_couchbase.c.

◆ rlm_couchbase

module_rlm_t rlm_couchbase
Initial value:
= {
.common = {
.name = "couchbase",
.inst_size = sizeof(rlm_couchbase_t),
.onload = mod_load,
.detach = mod_detach
},
.method_names = (module_method_name_t[]){
{ .name1 = "recv", .name2 = CF_IDENT_ANY, .method = mod_authorize },
{ .name1 = "accounting", .name2 = CF_IDENT_ANY, .method = mod_accounting },
}
}
#define CF_IDENT_ANY
Definition: cf_util.h:78
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:65
Specifies a module method identifier.
Definition: module_method.c:36
static const conf_parser_t config[]
Definition: base.c:188
static int mod_detach(module_detach_ctx_t const *mctx)
Detach the module.
static int mod_load(void)
static unlang_action_t mod_accounting(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Write accounting data to Couchbase documents.
static unlang_action_t mod_authorize(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Handle authorization requests using Couchbase document data.
Definition: rlm_couchbase.c:99
static const conf_parser_t module_config[]
Module Configuration.
Definition: rlm_couchbase.c:52
static int mod_instantiate(module_inst_ctx_t const *mctx)
Initialize the rlm_couchbase module.
static int instantiate(module_inst_ctx_t const *mctx)
Definition: rlm_rest.c:1312
@ MODULE_TYPE_THREAD_SAFE
Module is threadsafe.
Definition: module.h:49
#define MODULE_NAME_TERMINATOR
Definition: module.h:135

Definition at line 548 of file rlm_couchbase.c.

◆ rlm_couchbase_dict

fr_dict_autoload_t rlm_couchbase_dict
Initial value:
= {
{ .out = &dict_radius, .proto = "radius" },
{ NULL }
}
static fr_dict_t const * dict_radius
Definition: rlm_couchbase.c:68

Definition at line 71 of file rlm_couchbase.c.

◆ rlm_couchbase_dict_attr

fr_dict_attr_autoload_t rlm_couchbase_dict_attr
Initial value:
= {
{ .out = &attr_acct_status_type, .name = "Acct-Status-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius },
{ .out = &attr_acct_session_time, .name = "Acct-Session-Time", .type = FR_TYPE_UINT32, .dict = &dict_radius },
{ .out = &attr_event_timestamp, .name = "Event-Timestamp", .type = FR_TYPE_DATE, .dict = &dict_radius },
{ NULL }
}
@ FR_TYPE_DATE
Unix time stamp, always has value >2^31.
Definition: merged_model.c:111
@ FR_TYPE_UINT32
32 Bit unsigned integer.
Definition: merged_model.c:99
fr_dict_attr_t const * attr_acct_session_time
Definition: rlm_couchbase.c:77
fr_dict_attr_t const * attr_acct_status_type
Definition: rlm_couchbase.c:76
fr_dict_attr_t const * attr_event_timestamp
Definition: rlm_couchbase.c:78

Definition at line 81 of file rlm_couchbase.c.