26 RCSIDH(rest_h,
"$Id: 2e6b27549bff96c1e759cf24245aff02f629bb54 $")
28 #include <freeradius-devel/curl/base.h>
29 #include <freeradius-devel/curl/config.h>
30 #include <freeradius-devel/server/pairmove.h>
31 #include <freeradius-devel/util/slab.h>
36 #include <freeradius-devel/json/base.h>
38 #define REST_URI_MAX_LEN 2048
39 #define REST_BODY_MAX_LEN 8192
40 #define REST_BODY_ALLOC_CHUNK 1024
41 #define REST_BODY_MAX_ATTRS 256
274 fr_value_box_list_t *header;
307 char const *uri,
char const *body_data) CC_HINT(
nonnull (1,2,4,7));
316 #define rest_get_handle_code(_handle)(((rlm_rest_curl_context_t*)((fr_curl_io_request_t*)(_handle))->uctx)->response.code)
318 #define rest_get_handle_type(_handle)(((rlm_rest_curl_context_t*)((fr_curl_io_request_t*)(_handle))->uctx)->response.type)
Uctx data for timer and I/O functions.
Structure representing an individual request being passed to curl for processing.
static fr_time_delta_t timeout
Temporary structure to hold arguments for module calls.
rlm_rest_t const * instance
This instance of rlm_rest.
read_state_t state
Encoder state.
HIDDEN fr_dict_attr_t const * attr_rest_http_header
http_auth_type_t auth
HTTP auth type.
size_t rest_get_handle_data(char const **out, fr_curl_io_request_t *handle)
Extracts pointer to buffer containing response data.
struct curl_slist * headers
Any HTTP headers which will be sent with the request.
tmpl_t * header
Where to create pairs representing HTTP response headers.
request_t * request
Current request.
char * buffer
Raw incoming HTTP data.
fr_table_num_sorted_t const http_auth_table[]
int code
HTTP Status Code.
fr_curl_handle_t * mhandle
Thread specific multi handle.
write_state_t state
Decoder state.
void rest_io_module_signal(module_ctx_t const *mctx, request_t *request, fr_signal_t action)
bool fail_header_decode
Force header decoding to fail for debugging purposes.
char const * proxy
Send request via this proxy.
size_t used
Space used in buffer.
int rest_response_decode(rlm_rest_t const *instance, UNUSED rlm_rest_section_t const *section, request_t *request, fr_curl_io_request_t *randle)
http_body_type_t type
HTTP Content Type.
void * rest_mod_conn_create(TALLOC_CTX *ctx, void *instance, fr_time_delta_t timeout)
char * body
Pointer to the buffer which contains body data/ Only used when not performing chunked encoding.
bool fail_body_decode
Force body decoding to fail for debugging purposes.
http_body_type_t force_to
Override the Content-Type header in the response to force decoding as a particular type.
@ REST_HTTP_METHOD_DELETE
@ REST_HTTP_METHOD_UNKNOWN
@ REST_HTTP_METHOD_CUSTOM
Must always come last, should not be in method table.
size_t max_body_in
Maximum size of incoming data.
fr_dcursor_t cursor
Cursor pointing to the start of the list to encode.
http_body_type_t force_to
Force decoding the body type as a particular encoding.
@ REST_HTTP_BODY_UNSUPPORTED
@ REST_HTTP_BODY_NUM_ENTRIES
@ REST_HTTP_BODY_UNAVAILABLE
char const * method_str
The string version of the HTTP method.
void rest_io_xlat_signal(xlat_ctx_t const *xctx, request_t *request, fr_signal_t action)
Handle asynchronous cancellation of a request.
rlm_rest_section_t const * section
Section configuration.
fr_table_num_sorted_t const http_body_type_table[]
Conversion table for type config values.
fr_curl_conn_config_t conn_config
Configuration of slab allocated connection handles.
int http_negotiation
What HTTP version to negotiate, and how to.
HIDDEN fr_dict_t const * dict_freeradius
char const * body_str
The string version of the encoding/content type.
HIDDEN fr_dict_attr_t const * attr_rest_http_body
fr_table_num_sorted_t const http_method_table[]
Conversion table for method config values.
ssize_t rest_uri_host_unescape(char **out, UNUSED rlm_rest_t const *mod_inst, request_t *request, fr_curl_io_request_t *randle, char const *uri)
Unescapes the host portion of a URI string.
char const * force_to_str
Force decoding with this decoder.
rlm_rest_section_request_t request
Request configuration.
rlm_rest_response_t response
Response context data.
size_t(* rest_read_t)(void *ptr, size_t size, size_t nmemb, void *userdata)
void * decoder
Decoder specific data.
bool auth_is_set
Whether a value was provided for auth_str.
rlm_rest_section_t const * section
Section configuration.
int rest_request_config(module_ctx_t const *mctx, rlm_rest_section_t const *section, request_t *request, fr_curl_io_request_t *randle, http_method_t method, http_body_type_t type, char const *uri, char const *body_data))
Configures request curlopts.
void * encoder
Encoder specific data.
rlm_rest_section_t xlat
Configuration specific to xlat.
HIDDEN fr_dict_attr_t const * attr_rest_http_status_code
void rest_response_debug(request_t *request, fr_curl_io_request_t *handle)
Print out the response text.
rlm_rest_request_t request
Request context data.
http_method_t method
What HTTP method should be used, GET, POST etc...
fr_table_num_sorted_t const http_content_type_table[]
Conversion table for "Content-Type" header values.
const unsigned long http_curl_auth[REST_HTTP_AUTH_NUM_ENTRIES]
rlm_rest_section_response_t response
Response configuration.
rlm_rest_section_t section
Our mutated section config.
const http_body_type_t http_body_type_supported[REST_HTTP_BODY_NUM_ENTRIES]
Table of encoder/decoder support.
fr_time_delta_t timeout
Timeout timeval.
size_t rest_uri_escape(UNUSED request_t *request, char *out, size_t outlen, char const *raw, UNUSED void *arg)
URL encodes a string.
@ WRITE_STATE_PARSE_HEADERS
@ WRITE_STATE_PARSE_CONTENT
bool multiplex
Whether to perform multiple requests using a single connection.
rlm_rest_t const * inst
Instance of rlm_rest.
rlm_rest_section_t accounting
Configuration specific to accounting.
char const * name
Section name.
@ REST_HTTP_AUTH_NUM_ENTRIES
@ REST_HTTP_AUTH_GSSNEGOTIATE
@ REST_HTTP_AUTH_DIGEST_IE
@ REST_HTTP_AUTH_ANY_SAFE
void rest_response_error(request_t *request, fr_curl_io_request_t *handle)
Print out the response text as error lines.
size_t alloc
Space allocated for buffer.
rest_slab_list_t * slab
Slab list for connection handles.
size_t http_body_type_table_len
char const * connect_proxy
Send request via this proxy.
rlm_rest_section_t post_auth
Configuration specific to Post-auth.
size_t http_auth_table_len
size_t http_content_type_table_len
request_t * request
Current request.
http_body_type_t body
What encoding type should be used.
rlm_rest_section_t authorize
Configuration specific to authorisation.
size_t http_method_table_len
fr_curl_io_request_t * handle
curl easy handle servicing our request.
rlm_rest_t const * instance
This instance of rlm_rest.
char const * rest_no_proxy
Magic pointer value for determining if we should disable proxying.
rlm_rest_section_t authenticate
Configuration specific to authentication.
uint32_t chunk
Max chunk-size (mainly for testing the encoders)
bool require_auth
Whether HTTP-Auth is required or not.
Thread specific rlm_rest instance data.
Stores the state of a yielded xlat.
#define FR_SLAB_FUNCS(_name, _type)
Define type specific wrapper functions for slabs and slab elements.
#define FR_SLAB_TYPES(_name, _type)
Define type specific wrapper structs for slabs and slab elements.
fr_aka_sim_id_type_t type
An element in a lexicographically sorted array of name to num mappings.
A time delta, a difference in time measured in nanoseconds.
static size_t char ** out