Parses JSON responses.
More...
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/server/map_proc.h>
#include <freeradius-devel/util/base16.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/sbuff.h>
#include <freeradius-devel/util/types.h>
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/unlang/xlat_func.h>
#include <freeradius-devel/json/base.h>
Go to the source code of this file.
|
static int | _json_map_proc_get_value (TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t const *map, void *uctx) |
| Converts a string value into a fr_pair_t. More...
|
|
static xlat_action_t | json_encode_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
| Convert given attributes to a JSON document. More...
|
|
static xlat_action_t | json_escape (TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in, bool quote) |
|
static xlat_action_t | json_escape_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
| Ensure contents are escaped correctly for a JSON document. More...
|
|
static xlat_action_t | json_jpath_validate_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
| Determine if a jpath expression is valid. More...
|
|
static xlat_action_t | json_quote_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
| Ensure contents are quoted correctly for a JSON document. More...
|
|
static int | mod_bootstrap (module_inst_ctx_t const *mctx) |
|
static int | mod_instantiate (module_inst_ctx_t const *mctx) |
|
static int | mod_load (void) |
|
static unlang_action_t | mod_map_proc (rlm_rcode_t *p_result, UNUSED void const *mod_inst, void *proc_inst, request_t *request, fr_value_box_list_t *json, map_list_t const *maps) |
| Parses a JSON string, and executes jpath queries against it to map values to attributes. More...
|
|
static int | mod_map_proc_instantiate (CONF_SECTION *cs, UNUSED void const *mod_inst, void *proc_inst, tmpl_t const *src, map_list_t const *maps) |
| Pre-parse and validate literal jpath expressions for maps. More...
|
|
static void | mod_unload (void) |
|
Parses JSON responses.
- Id
- 8cc447c7d890b2870d66730ab44ea78371ef73f7
- Author
- Arran Cudbard-Bell
-
Matthew Newton
- Copyright
- 2015 Arran Cudbard-Bell (a.cud.nosp@m.bard.nosp@m.b@fre.nosp@m.erad.nosp@m.ius.o.nosp@m.rg)
-
2015,2020 Network RADIUS SAS (legal.nosp@m.@net.nosp@m.workr.nosp@m.adiu.nosp@m.s.com)
-
2015 The FreeRADIUS Server Project
Definition in file rlm_json.c.
◆ rlm_json_jpath_cache
struct rlm_json_jpath_cache |
◆ rlm_json_jpath_to_eval_t
struct rlm_json_jpath_to_eval_t |
◆ rlm_json_t
rlm_json module instance
Definition at line 57 of file rlm_json.c.
◆ rlm_json_jpath_cache_t
Forms a linked list of jpath head node pointers (a list of jpaths)
Definition at line 62 of file rlm_json.c.
◆ _json_map_proc_get_value()
Converts a string value into a fr_pair_t.
- Parameters
-
[in,out] | ctx | to allocate fr_pair_t (s). |
[out] | out | where to write the resulting fr_pair_t. |
[in] | request | The current request. |
[in] | map | to process. |
[in] | uctx | The json tree/jpath expression to evaluate. |
- Returns
- 0 on success.
- -1 on failure.
Definition at line 404 of file rlm_json.c.
◆ json_escape()
◆ mod_bootstrap()
◆ mod_instantiate()
◆ mod_load()
static int mod_load |
( |
void |
| ) |
|
|
static |
◆ mod_map_proc()
Parses a JSON string, and executes jpath queries against it to map values to attributes.
- Parameters
-
p_result | Result of applying map:
|
mod_inst | unused. |
proc_inst | cached jpath sequences. |
request | The current request. |
json | JSON string to parse. |
maps | Head of the map list. |
- Returns
- UNLANG_ACTION_CALCULATE_RESULT
Definition at line 454 of file rlm_json.c.
◆ mod_map_proc_instantiate()
static int mod_map_proc_instantiate |
( |
CONF_SECTION * |
cs, |
|
|
UNUSED void const * |
mod_inst, |
|
|
void * |
proc_inst, |
|
|
tmpl_t const * |
src, |
|
|
map_list_t const * |
maps |
|
) |
| |
|
static |
Pre-parse and validate literal jpath expressions for maps.
- Parameters
-
[in] | cs | CONF_SECTION that defined the map instance. |
[in] | mod_inst | module instance (unused). |
[in] | proc_inst | the cache structure to fill. |
[in] | src | Where to get the JSON data from. |
[in] | maps | set of maps to translate to jpaths. |
- Returns
-
Definition at line 328 of file rlm_json.c.
◆ mod_unload()
static void mod_unload |
( |
void |
| ) |
|
|
static |
◆ json_arg_parse_rules
fr_sbuff_parse_rules_t const json_arg_parse_rules |
|
static |
Initial value:= {
)
}
#define L(_str)
Helper for initialising arrays of string literals.
#define FR_SBUFF_TERMS(...)
Initialise a terminal structure with a list of sorted strings.
Definition at line 46 of file rlm_json.c.
◆ json_encode_xlat_arg
Initial value:= {
}
@ FR_TYPE_STRING
String of printable characters.
#define XLAT_ARG_PARSER_TERMINATOR
Definition at line 194 of file rlm_json.c.
◆ json_escape_xlat_arg
◆ json_jpath_validate_xlat_arg
◆ module_config
Initial value:= {
}
#define CONF_PARSER_TERMINATOR
#define FR_CONF_OFFSET_SUBSECTION(_name, _flags, _struct, _field, _subcs)
conf_parser_t which populates a sub-struct using a CONF_SECTION
struct fr_json_format_s fr_json_format_t
conf_parser_t const fr_json_format_config[]
int format(printf, 5, 0))
Definition at line 62 of file rlm_json.c.
◆ rlm_json
Initial value:= {
.common = {
.name = "json",
}
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
static int mod_load(void)
static int mod_bootstrap(module_inst_ctx_t const *mctx)
static void mod_unload(void)
static int mod_instantiate(module_inst_ctx_t const *mctx)
static conf_parser_t const module_config[]
static int instantiate(module_inst_ctx_t const *mctx)
Definition at line 620 of file rlm_json.c.