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

Integrate FreeRADIUS with RESTfull APIs. More...

#include <talloc.h>
#include <freeradius-devel/curl/base.h>
#include <freeradius-devel/curl/xlat.h>
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/cf_parse.h>
#include <freeradius-devel/server/cf_util.h>
#include <freeradius-devel/server/global_lib.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/server/tmpl.h>
#include <freeradius-devel/server/tmpl_escape.h>
#include <freeradius-devel/server/pairmove.h>
#include <freeradius-devel/server/log.h>
#include <freeradius-devel/tls/base.h>
#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/table.h>
#include <freeradius-devel/util/uri.h>
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/unlang/call_env.h>
#include <freeradius-devel/unlang/xlat_func.h>
#include <freeradius-devel/unlang/xlat.h>
#include "rest.h"
+ Include dependency graph for rlm_rest.c:

Go to the source code of this file.

Macros

#define REST_CALL_ENV_REQUEST_COMMON(_dflt_username, _dflt_password)
 
#define REST_CALL_ENV_RESPONSE_COMMON    { FR_CALL_ENV_PARSE_ONLY_OFFSET("header", FR_TYPE_STRING, CALL_ENV_FLAG_ATTRIBUTE, rlm_rest_call_env_t, response.header) }, \
 
#define REST_CALL_ENV_SECTION(_var, _section, _dflt_username, _dflt_password)
 
#define SECTION_REQUEST_COMMON
 

Functions

static int _mod_conn_free (fr_curl_io_request_t *randle)
 
static int _rest_uri_part_escape_uctx_free (void *uctx)
 
static int instantiate (module_inst_ctx_t const *mctx)
 
static unlang_action_t mod_accounting (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static unlang_action_t mod_accounting_result (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static unlang_action_t mod_authenticate (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static unlang_action_t mod_authenticate_result (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static unlang_action_t mod_authorize (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static unlang_action_t mod_authorize_result (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static int mod_bootstrap (module_inst_ctx_t const *mctx)
 
static int mod_load (void)
 Initialises libcurl. More...
 
static unlang_action_t mod_post_auth (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static unlang_action_t mod_post_auth_result (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static int mod_thread_detach (module_thread_inst_ctx_t const *mctx)
 Cleanup all outstanding requests associated with this thread. More...
 
static int mod_thread_instantiate (module_thread_inst_ctx_t const *mctx)
 Create a thread specific multihandle. More...
 
static int parse_sub_section (rlm_rest_t *inst, CONF_SECTION *parent, conf_parser_t const *config_items, rlm_rest_section_t *config, char const *name)
 
 REST_CALL_ENV_SECTION (rest_call_env_accounting, "accounting",,)
 
 REST_CALL_ENV_SECTION (rest_call_env_authenticate, "authenticate",.pair.dflt="&User-Name",.pair.dflt="&User-Password")
 
 REST_CALL_ENV_SECTION (rest_call_env_authorize, "authorize",,)
 
 REST_CALL_ENV_SECTION (rest_call_env_post_auth, "post-auth",,)
 
static int rest_conn_alloc (fr_curl_io_request_t *randle, void *uctx)
 
static int rest_proxy_parse (UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
 
static int rest_request_cleanup (fr_curl_io_request_t *randle, UNUSED void *uctx)
 Cleans up after a REST request. More...
 
static int rest_uri_part_escape (fr_value_box_t *vb, UNUSED void *uctx)
 URL escape a single box forming part of a URL. More...
 
static int rest_uri_part_escape (fr_value_box_t *vb, void *uctx)
 
static void * rest_uri_part_escape_uctx_alloc (UNUSED request_t *request, void const *uctx)
 Allocate an escape uctx to pass to fr_uri_escape. More...
 
static xlat_action_t rest_xlat (UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in)
 Simple xlat to read text data from a URL. More...
 
static xlat_action_t rest_xlat_resume (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, UNUSED fr_value_box_list_t *in)
 
static int rlm_rest_perform (module_ctx_t const *mctx, rlm_rest_section_t const *section, fr_curl_io_request_t *randle, request_t *request)
 
static int rlm_rest_status_update (request_t *request, void *handle)
 Update the status attribute. More...
 

Variables

fr_dict_attr_t const * attr_rest_http_body
 
fr_dict_attr_t const * attr_rest_http_header
 
fr_dict_attr_t const * attr_rest_http_status_code
 
static fr_dict_attr_t const * attr_user_name
 
static fr_dict_attr_t const * attr_user_password
 
fr_dict_t const * dict_freeradius
 
static fr_dict_t const * dict_radius
 
static fr_table_num_sorted_t const http_negotiation_table []
 
static size_t http_negotiation_table_len = NUM_ELEMENTS(http_negotiation_table)
 
static const conf_parser_t module_config []
 
static const call_env_method_t rest_call_env_xlat
 
char const * rest_no_proxy = "*"
 Unique pointer used to determine if we should explicitly disable proxying. More...
 
static fr_uri_part_t const rest_uri_parts []
 
static xlat_arg_parser_t const rest_xlat_args []
 
module_rlm_t rlm_rest
 
fr_dict_autoload_t rlm_rest_dict []
 
fr_dict_attr_autoload_t rlm_rest_dict_attr []
 
global_lib_autoinst_t const *const rlm_rest_lib []
 
static const conf_parser_t section_config []
 
static const conf_parser_t section_request_config []
 
static const conf_parser_t section_response_config []
 
static const conf_parser_t xlat_config []
 
static const conf_parser_t xlat_request_config []
 

Detailed Description

Integrate FreeRADIUS with RESTfull APIs.

Id
7dbe316f97d44d8a301a68d8bc7dc7e6ff0bbb75

Definition in file rlm_rest.c.

Macro Definition Documentation

◆ REST_CALL_ENV_REQUEST_COMMON

#define REST_CALL_ENV_REQUEST_COMMON (   _dflt_username,
  _dflt_password 
)
Value:
rlm_rest_call_env_t, request.username), .pair.dflt_quote = T_BARE_WORD, _dflt_username }, \
rlm_rest_call_env_t, request.password), .pair.dflt_quote = T_BARE_WORD, _dflt_password }, \
@ CALL_ENV_FLAG_CONCAT
If the tmpl produced multiple boxes they should be concatenated.
Definition: call_env.h:74
@ CALL_ENV_FLAG_SINGLE
If the tmpl produces more than one box this is an error.
Definition: call_env.h:75
@ CALL_ENV_FLAG_SECRET
The value is a secret, and should not be logged.
Definition: call_env.h:89
@ CALL_ENV_FLAG_MULTI
Multiple instances of the conf pairs are allowed.
Definition: call_env.h:76
@ CALL_ENV_FLAG_NULLABLE
Tmpl expansions are allowed to produce no output.
Definition: call_env.h:78
#define FR_CALL_ENV_OFFSET(_name, _cast_type, _flags, _struct, _field)
Specify a call_env_parser_t which writes out runtime results to the specified field.
Definition: call_env.h:316
@ FR_TYPE_STRING
String of printable characters.
Definition: merged_model.c:83
@ T_BARE_WORD
Definition: token.h:120

Definition at line 186 of file rlm_rest.c.

◆ REST_CALL_ENV_RESPONSE_COMMON

#define REST_CALL_ENV_RESPONSE_COMMON    { FR_CALL_ENV_PARSE_ONLY_OFFSET("header", FR_TYPE_STRING, CALL_ENV_FLAG_ATTRIBUTE, rlm_rest_call_env_t, response.header) }, \

Definition at line 194 of file rlm_rest.c.

◆ REST_CALL_ENV_SECTION

#define REST_CALL_ENV_SECTION (   _var,
  _section,
  _dflt_username,
  _dflt_password 
)

Definition at line 197 of file rlm_rest.c.

◆ SECTION_REQUEST_COMMON

#define SECTION_REQUEST_COMMON
Value:
{ FR_CONF_OFFSET("body", rlm_rest_section_request_t, body_str), .dflt = "none" }, \
/* User authentication */ \
.func = cf_table_parse_int, .uctx = &(cf_table_parse_ctx_t){ .table = http_auth_table, .len = &http_auth_table_len }, .dflt = "none" }, \
{ FR_CONF_OFFSET("require_auth", rlm_rest_section_request_t, require_auth), .dflt = "no" }, \
{ FR_CONF_OFFSET("chunk", rlm_rest_section_request_t, chunk), .dflt = "0" } \
int cf_table_parse_int(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic function for parsing conf pair values as int.
Definition: cf_parse.c:1474
#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
#define FR_CONF_OFFSET_IS_SET(_name, _type, _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:282
@ FR_TYPE_VOID
User data.
Definition: merged_model.c:127
fr_table_num_sorted_t const http_auth_table[]
Definition: rest.c:160
size_t http_auth_table_len
Definition: rest.c:172

Definition at line 114 of file rlm_rest.c.

Function Documentation

◆ _mod_conn_free()

static int _mod_conn_free ( fr_curl_io_request_t randle)
static

Definition at line 1180 of file rlm_rest.c.

+ Here is the caller graph for this function:

◆ _rest_uri_part_escape_uctx_free()

static int _rest_uri_part_escape_uctx_free ( void *  uctx)
static

Definition at line 334 of file rlm_rest.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instantiate()

static int instantiate ( module_inst_ctx_t const *  mctx)
static

Definition at line 1312 of file rlm_rest.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_accounting()

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

Definition at line 955 of file rlm_rest.c.

+ Here is the call graph for this function:

◆ mod_accounting_result()

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

Definition at line 904 of file rlm_rest.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_authenticate()

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

Definition at line 845 of file rlm_rest.c.

+ Here is the call graph for this function:

◆ mod_authenticate_result()

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

Definition at line 761 of file rlm_rest.c.

+ Here is the call graph for this function:
+ Here is the caller 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

Definition at line 734 of file rlm_rest.c.

+ Here is the call graph for this function:

◆ mod_authorize_result()

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

Definition at line 648 of file rlm_rest.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_bootstrap()

static int mod_bootstrap ( module_inst_ctx_t const *  mctx)
static

Definition at line 1345 of file rlm_rest.c.

+ Here is the call graph for this function:

◆ mod_load()

static int mod_load ( void  )
static

Initialises libcurl.

Allocates global variables and memory required for libcurl to function. MUST only be called once per module instance.

mod_unload must not be called if mod_load fails.

See also
mod_unload
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1370 of file rlm_rest.c.

+ Here is the call graph for this function:

◆ mod_post_auth()

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

Definition at line 1033 of file rlm_rest.c.

+ Here is the call graph for this function:

◆ mod_post_auth_result()

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

Definition at line 982 of file rlm_rest.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_thread_detach()

static int mod_thread_detach ( module_thread_inst_ctx_t const *  mctx)
static

Cleanup all outstanding requests associated with this thread.

Destroys all curl easy handles, and then the multihandle associated with this thread.

Parameters
[in]mctxdata to destroy.
Returns
0

Definition at line 1292 of file rlm_rest.c.

+ Here is the call graph for this function:

◆ mod_thread_instantiate()

static int mod_thread_instantiate ( module_thread_inst_ctx_t const *  mctx)
static

Create a thread specific multihandle.

Easy handles representing requests are added to the curl multihandle with the multihandle used for mux/demux.

Parameters
[in]mctxThread instantiation data.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1262 of file rlm_rest.c.

+ Here is the call graph for this function:

◆ parse_sub_section()

static int parse_sub_section ( rlm_rest_t inst,
CONF_SECTION parent,
conf_parser_t const *  config_items,
rlm_rest_section_t config,
char const *  name 
)
static

Definition at line 1060 of file rlm_rest.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ REST_CALL_ENV_SECTION() [1/4]

REST_CALL_ENV_SECTION ( rest_call_env_accounting  ,
"accounting"   
)

◆ REST_CALL_ENV_SECTION() [2/4]

REST_CALL_ENV_SECTION ( rest_call_env_authenticate  ,
"authenticate"  ,
.pair.  dflt = "&User-Name",
.pair.  dflt = "&User-Password" 
)

◆ REST_CALL_ENV_SECTION() [3/4]

REST_CALL_ENV_SECTION ( rest_call_env_authorize  ,
"authorize"   
)

◆ REST_CALL_ENV_SECTION() [4/4]

REST_CALL_ENV_SECTION ( rest_call_env_post_auth  ,
"post-auth"   
)

◆ rest_conn_alloc()

static int rest_conn_alloc ( fr_curl_io_request_t randle,
void *  uctx 
)
static

Definition at line 1228 of file rlm_rest.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rest_proxy_parse()

static int rest_proxy_parse ( UNUSED TALLOC_CTX *  ctx,
void *  out,
UNUSED void *  parent,
CONF_ITEM ci,
UNUSED conf_parser_t const *  rule 
)
static

Definition at line 95 of file rlm_rest.c.

+ Here is the call graph for this function:

◆ rest_request_cleanup()

static int rest_request_cleanup ( fr_curl_io_request_t randle,
UNUSED void *  uctx 
)
static

Cleans up after a REST request.

Resets all options associated with a CURL handle, and frees any headers associated with it.

Calls rest_read_ctx_free and rest_response_free to free any memory used by context data.

Parameters
[in]randleto cleanup.
[in]uctxunused.

Definition at line 1197 of file rlm_rest.c.

+ Here is the caller graph for this function:

◆ rest_uri_part_escape() [1/2]

static int rest_uri_part_escape ( fr_value_box_t vb,
UNUSED void *  uctx 
)
static

URL escape a single box forming part of a URL.

Parameters
[in]vbto escape
[in]uctxUNUSED context containing CURL handle
Returns
  • 0 on success
  • -1 on failure

Definition at line 369 of file rlm_rest.c.

+ Here is the call graph for this function:

◆ rest_uri_part_escape() [2/2]

static int rest_uri_part_escape ( fr_value_box_t vb,
void *  uctx 
)
static

◆ rest_uri_part_escape_uctx_alloc()

static void * rest_uri_part_escape_uctx_alloc ( UNUSED request_t request,
void const *  uctx 
)
static

Allocate an escape uctx to pass to fr_uri_escape.

Parameters
[in]requestUNUSED.
[in]uctxpointer to the start of the uri_parts array.
Returns
A new fr_uri_escape_ctx_t.

Definition at line 345 of file rlm_rest.c.

+ Here is the call graph for this function:

◆ rest_xlat_resume()

static xlat_action_t rest_xlat_resume ( TALLOC_CTX *  ctx,
fr_dcursor_t out,
xlat_ctx_t const *  xctx,
request_t request,
UNUSED fr_value_box_list_t *  in 
)
static

Definition at line 422 of file rlm_rest.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rlm_rest_perform()

static int rlm_rest_perform ( module_ctx_t const *  mctx,
rlm_rest_section_t const *  section,
fr_curl_io_request_t randle,
request_t request 
)
static

Definition at line 392 of file rlm_rest.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rlm_rest_status_update()

static int rlm_rest_status_update ( request_t request,
void *  handle 
)
static

Update the status attribute.

Parameters
[in]requestThe current request.
[in]handlerest handle.
Returns
  • 0 if status was updated successfully.
  • -1 if status was not updated successfully.

Definition at line 309 of file rlm_rest.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ attr_rest_http_body

fr_dict_attr_t const* attr_rest_http_body

Definition at line 279 of file rlm_rest.c.

◆ attr_rest_http_header

fr_dict_attr_t const* attr_rest_http_header

Definition at line 280 of file rlm_rest.c.

◆ attr_rest_http_status_code

fr_dict_attr_t const* attr_rest_http_status_code

Definition at line 281 of file rlm_rest.c.

◆ attr_user_name

fr_dict_attr_t const* attr_user_name
static

Definition at line 282 of file rlm_rest.c.

◆ attr_user_password

fr_dict_attr_t const* attr_user_password
static

Definition at line 283 of file rlm_rest.c.

◆ dict_freeradius

fr_dict_t const* dict_freeradius

Definition at line 269 of file rlm_rest.c.

◆ dict_radius

fr_dict_t const* dict_radius
static

Definition at line 270 of file rlm_rest.c.

◆ http_negotiation_table

fr_table_num_sorted_t const http_negotiation_table[]
static
Initial value:
= {
{ L("1.0"), CURL_HTTP_VERSION_1_0 },
{ L("1.1"), CURL_HTTP_VERSION_1_1 },
{ L("default"), CURL_HTTP_VERSION_NONE }
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition: build.h:207

Definition at line 64 of file rlm_rest.c.

◆ http_negotiation_table_len

size_t http_negotiation_table_len = NUM_ELEMENTS(http_negotiation_table)
static

Definition at line 88 of file rlm_rest.c.

◆ module_config

const conf_parser_t module_config[]
static
Initial value:
= {
{ FR_CONF_DEPRECATED("connect_timeout", rlm_rest_t, connect_timeout) },
{ FR_CONF_OFFSET("connect_proxy", rlm_rest_t, connect_proxy), .func = rest_proxy_parse },
{ FR_CONF_OFFSET("http_negotiation", rlm_rest_t, http_negotiation),
.dflt = "default" },
{ FR_CONF_OFFSET_SUBSECTION("connection", 0, rlm_rest_t, conn_config, fr_curl_conn_config) },
{ FR_CONF_OFFSET("fail_header_decode", rlm_rest_t, fail_header_decode), .dflt = "no" },
{ FR_CONF_OFFSET("fail_body_decode", rlm_rest_t, fail_body_decode), .dflt = "no" },
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:626
#define FR_CONF_DEPRECATED(_name, _struct, _field)
conf_parser_t entry which raises an error if a matching CONF_PAIR is found
Definition: cf_parse.h:385
#define FR_CONF_OFFSET_SUBSECTION(_name, _flags, _struct, _field, _subcs)
conf_parser_t which populates a sub-struct using a CONF_SECTION
Definition: cf_parse.h:297
conf_parser_t fr_curl_conn_config[]
Definition: base.c:84
static fr_table_num_sorted_t const http_negotiation_table[]
Definition: rlm_rest.c:64
static int rest_proxy_parse(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
Definition: rlm_rest.c:95
static size_t http_negotiation_table_len
Definition: rlm_rest.c:88

Definition at line 164 of file rlm_rest.c.

◆ rest_call_env_xlat

const call_env_method_t rest_call_env_xlat
static
Initial value:
= {
.env = (call_env_parser_t[]){
})) },
})) },
})
) },
}
}
#define CALL_ENV_TERMINATOR
Definition: call_env.h:212
#define FR_CALL_ENV_METHOD_OUT(_inst)
Helper macro for populating the size/type fields of a call_env_method_t from the output structure typ...
Definition: call_env.h:216
@ CALL_ENV_FLAG_NONE
Definition: call_env.h:72
#define FR_CALL_ENV_SUBSECTION(_name, _ident2, _flags, _subcs)
Specify a call_env_parser_t which defines a nested subsection.
Definition: call_env.h:378
Per method call config.
Definition: call_env.h:171
#define REST_CALL_ENV_RESPONSE_COMMON
Definition: rlm_rest.c:194
#define REST_CALL_ENV_REQUEST_COMMON(_dflt_username, _dflt_password)
Definition: rlm_rest.c:186

Definition at line 247 of file rlm_rest.c.

◆ rest_no_proxy

char const* rest_no_proxy = "*"

Unique pointer used to determine if we should explicitly disable proxying.

Magic pointer value for determining if we should disable proxying.

Definition at line 93 of file rlm_rest.c.

◆ rest_uri_parts

fr_uri_part_t const rest_uri_parts[]
static
Initial value:
= {
{ .name = "scheme", .safe_for = CURL_URI_SAFE_FOR, .terminals = &FR_SBUFF_TERMS(L(":")), .part_adv = { [':'] = 1 }, .extra_skip = 2 },
{ .name = "host", .safe_for = CURL_URI_SAFE_FOR, .terminals = &FR_SBUFF_TERMS(L(":"), L("/")), .part_adv = { [':'] = 1, ['/'] = 2 }, .func = rest_uri_part_escape },
{ .name = "port", .safe_for = CURL_URI_SAFE_FOR, .terminals = &FR_SBUFF_TERMS(L("/")), .part_adv = { ['/'] = 1 } },
{ .name = "method", .safe_for = CURL_URI_SAFE_FOR, .terminals = &FR_SBUFF_TERMS(L("?")), .part_adv = { ['?'] = 1 }, .func = rest_uri_part_escape },
{ .name = "param", .safe_for = CURL_URI_SAFE_FOR, .func = rest_uri_part_escape },
}
#define CURL_URI_SAFE_FOR
safe for value suitable for all users of the curl library
Definition: xlat.h:36
static int rest_uri_part_escape(fr_value_box_t *vb, void *uctx)
#define FR_SBUFF_TERMS(...)
Initialise a terminal structure with a list of sorted strings.
Definition: sbuff.h:167
#define XLAT_URI_PART_TERMINATOR
Definition: uri.h:66

Definition at line 55 of file rlm_rest.c.

◆ rest_xlat_args

xlat_arg_parser_t const rest_xlat_args[]
static
Initial value:
= {
{ .required = true, .safe_for = CURL_URI_SAFE_FOR, .type = FR_TYPE_STRING },
{ .variadic = XLAT_ARG_VARIADIC_EMPTY_KEEP, .type = FR_TYPE_STRING },
}
@ XLAT_ARG_VARIADIC_EMPTY_KEEP
Empty argument groups are left alone, and either passed through as empty groups or null boxes.
Definition: xlat.h:137
#define XLAT_ARG_PARSER_TERMINATOR
Definition: xlat.h:166

Definition at line 497 of file rlm_rest.c.

◆ rlm_rest

module_rlm_t rlm_rest
Initial value:
= {
.common = {
.name = "rest",
.inst_size = sizeof(rlm_rest_t),
.thread_inst_size = sizeof(rlm_rest_thread_t),
.config = module_config,
.onload = mod_load,
.bootstrap = mod_bootstrap,
.instantiate = instantiate,
.thread_instantiate = mod_thread_instantiate,
.thread_detach = mod_thread_detach
},
.method_names = (module_method_name_t[]){
{ .name1 = "authorize", .name2 = CF_IDENT_ANY, .method = mod_authorize, .method_env = &rest_call_env_authorize },
{ .name1 = "recv", .name2 = "accounting-request", .method = mod_accounting, .method_env = &rest_call_env_accounting },
{ .name1 = "recv", .name2 = CF_IDENT_ANY, .method = mod_authorize, .method_env = &rest_call_env_authorize },
{ .name1 = "accounting", .name2 = CF_IDENT_ANY, .method = mod_accounting, .method_env = &rest_call_env_accounting },
{ .name1 = "authenticate", .name2 = CF_IDENT_ANY, .method = mod_authenticate, .method_env = &rest_call_env_authenticate },
{ .name1 = "send", .name2 = CF_IDENT_ANY, .method = mod_post_auth, .method_env = &rest_call_env_post_auth },
}
}
#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
Thread specific rlm_rest instance data.
Definition: rest.h:180
static int mod_load(void)
Initialises libcurl.
Definition: rlm_rest.c:1370
static int instantiate(module_inst_ctx_t const *mctx)
Definition: rlm_rest.c:1312
static unlang_action_t mod_authenticate(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition: rlm_rest.c:845
static int mod_bootstrap(module_inst_ctx_t const *mctx)
Definition: rlm_rest.c:1345
static unlang_action_t mod_accounting(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition: rlm_rest.c:955
static unlang_action_t mod_authorize(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition: rlm_rest.c:734
static int mod_thread_instantiate(module_thread_inst_ctx_t const *mctx)
Create a thread specific multihandle.
Definition: rlm_rest.c:1262
static const conf_parser_t module_config[]
Definition: rlm_rest.c:164
static int mod_thread_detach(module_thread_inst_ctx_t const *mctx)
Cleanup all outstanding requests associated with this thread.
Definition: rlm_rest.c:1292
static unlang_action_t mod_post_auth(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition: rlm_rest.c:1033
@ MODULE_TYPE_THREAD_SAFE
Module is threadsafe.
Definition: module.h:49
#define MODULE_NAME_TERMINATOR
Definition: module.h:135

Definition at line 1392 of file rlm_rest.c.

◆ rlm_rest_dict

fr_dict_autoload_t rlm_rest_dict
Initial value:
= {
{ .out = &dict_freeradius, .proto = "freeradius" },
{ .out = &dict_radius, .proto = "radius" },
{ NULL }
}
fr_dict_t const * dict_freeradius
Definition: rlm_rest.c:269
static fr_dict_t const * dict_radius
Definition: rlm_rest.c:270

Definition at line 273 of file rlm_rest.c.

◆ rlm_rest_dict_attr

fr_dict_attr_autoload_t rlm_rest_dict_attr
Initial value:
= {
{ .out = &attr_rest_http_body, .name = "REST-HTTP-Body", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
{ .out = &attr_rest_http_header, .name = "REST-HTTP-Header", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
{ .out = &attr_rest_http_status_code, .name = "REST-HTTP-Status-Code", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
{ .out = &attr_user_name, .name = "User-Name", .type = FR_TYPE_STRING, .dict = &dict_radius },
{ .out = &attr_user_password, .name = "User-Password", .type = FR_TYPE_STRING, .dict = &dict_radius },
{ NULL }
}
@ FR_TYPE_UINT32
32 Bit unsigned integer.
Definition: merged_model.c:99
static fr_dict_attr_t const * attr_user_password
Definition: rlm_rest.c:283
fr_dict_attr_t const * attr_rest_http_header
Definition: rlm_rest.c:280
fr_dict_attr_t const * attr_rest_http_status_code
Definition: rlm_rest.c:281
fr_dict_attr_t const * attr_rest_http_body
Definition: rlm_rest.c:279
static fr_dict_attr_t const * attr_user_name
Definition: rlm_rest.c:282

Definition at line 286 of file rlm_rest.c.

◆ rlm_rest_lib

global_lib_autoinst_t const *const rlm_rest_lib
Initial value:
= {
}
#define GLOBAL_LIB_TERMINATOR
Definition: global_lib.h:51
global_lib_autoinst_t fr_curl_autoinst
Definition: base.c:342

Definition at line 296 of file rlm_rest.c.

◆ section_config

const conf_parser_t section_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("timeout", rlm_rest_section_t, timeout), .dflt = "4.0" },
}
static fr_time_delta_t timeout
Definition: dhcpclient.c:54
conf_parser_t fr_curl_tls_config[]
Definition: base.c:56
static const conf_parser_t section_request_config[]
Definition: rlm_rest.c:122
static const conf_parser_t section_response_config[]
Definition: rlm_rest.c:129

Definition at line 135 of file rlm_rest.c.

◆ section_request_config

const conf_parser_t section_request_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("method", rlm_rest_section_request_t, method_str), .dflt = "GET" },
}
#define SECTION_REQUEST_COMMON
Definition: rlm_rest.c:114

Definition at line 122 of file rlm_rest.c.

◆ section_response_config

const conf_parser_t section_response_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("force_to", rlm_rest_section_response_t, force_to_str) },
{ FR_CONF_OFFSET_TYPE_FLAGS("max_body_in", FR_TYPE_SIZE, 0, rlm_rest_section_response_t, max_body_in), .dflt = "16k" },
}
#define FR_CONF_OFFSET_TYPE_FLAGS(_name, _type, _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:241
@ FR_TYPE_SIZE
Unsigned integer capable of representing any memory address on the local system.
Definition: merged_model.c:115

Definition at line 129 of file rlm_rest.c.

◆ xlat_config

const conf_parser_t xlat_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("timeout", rlm_rest_section_t, timeout), .dflt = "4.0" },
}
static const conf_parser_t xlat_request_config[]
Definition: rlm_rest.c:147

Definition at line 152 of file rlm_rest.c.

◆ xlat_request_config

const conf_parser_t xlat_request_config[]
static
Initial value:

Definition at line 147 of file rlm_rest.c.