25 RCSID(
"$Id: 9e6800ec4bfaf776927b5adfd62a4e698a5a2c94 $")
27 #include <freeradius-devel/server/base.h>
28 #include <freeradius-devel/server/module_rlm.h>
29 #include <freeradius-devel/unlang/interpret.h>
30 #include <freeradius-devel/util/base32.h>
32 #include <freeradius-devel/unlang/call_env.h>
46 .pair.dflt =
"&control.TOTP.Secret", .pair.dflt_quote =
T_BARE_WORD },
49 .pair.dflt =
"&control.TOTP.key", .pair.dflt_quote =
T_BARE_WORD },
52 .pair.dflt =
"&request.TOTP.From-User", .pair.dflt_quote =
T_BARE_WORD },
90 if (user_password->vb_length == 0) {
91 RWARN(
"TOTP.From-User is empty");
95 if ((user_password->vb_length != 6) && (user_password->vb_length != 8)) {
96 RWARN(
"TOTP.From-User has incorrect length. Expected 6 or 8, got %zu", user_password->vb_length);
104 our_key = key->vb_octets;
105 our_keylen = key->vb_length;
114 RERROR(
"TOTP.Secret cannot be decoded");
161 if (
inst->totp.otp_length == 7)
inst->totp.otp_length = 8;
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
static int const char char buffer[256]
#define fr_base32_decode(_out, _in, _expect_padding, _no_trailing)
#define CALL_ENV_TERMINATOR
#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...
@ CALL_ENV_FLAG_NULLABLE
Tmpl expansions are allowed to produce no output.
#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.
#define CONF_PARSER_TERMINATOR
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)
#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
Defines a CONF_PAIR to C data type mapping.
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
@ FR_TYPE_STRING
String of printable characters.
void * env_data
Per call environment data.
module_instance_t const * mi
Instance of the module being instantiated.
module_instance_t * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for module calls.
Temporary structure to hold arguments for instantiation calls.
module_t common
Common fields presented by all modules.
static const conf_parser_t config[]
#define RETURN_MODULE_REJECT
#define RETURN_MODULE_NOOP
rlm_rcode_t
Return codes indicating the result of the module call.
static int instantiate(module_inst_ctx_t const *mctx)
static const call_env_method_t method_env
static unlang_action_t mod_authenticate(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
fr_value_box_t user_password
static const conf_parser_t module_config[]
static int mod_instantiate(module_inst_ctx_t const *mctx)
struct rlm_totp_t rlm_totp_t
#define FR_SBUFF_IN(_start, _len_or_end)
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
void * data
Module's instance data.
#define MODULE_BINDING_TERMINATOR
Terminate a module binding list.
Named methods exported by a module.
eap_aka_sim_process_conf_t * inst
#define talloc_get_type_abort_const
static int64_t fr_time_to_sec(fr_time_t when)
Convert an fr_time_t (internal time) to number of sec since the unix epoch (wallclock time)
int fr_totp_cmp(fr_totp_t const *cfg, request_t *request, time_t now, uint8_t const *key, size_t keylen, char const *totp)
Implement RFC 6238 TOTP algorithm (HMAC-SHA1).
#define fr_type_is_null(_x)