25 RCSID(
"$Id: 8a292c3a3b7f06e78b647e9f4b420b34f42efbc9 $")
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 },
112 if (
inst->totp.otp_length == 7)
inst->totp.otp_length = 8;
134 if (user_password->vb_length == 0) {
135 RWARN(
"TOTP.From-User is empty");
139 if ((user_password->vb_length != 6) && (user_password->vb_length != 8)) {
140 RWARN(
"TOTP.From-User has incorrect length. Expected 6 or 8, got %zu", user_password->vb_length);
148 our_key = key->vb_octets;
149 our_keylen = key->vb_length;
158 RERROR(
"TOTP.Secret cannot be decoded");
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.
A section grouping multiple CONF_PAIR.
char const * cf_section_name2(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
char const * cf_section_name1(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
void *_CONST data
Module instance's parsed configuration.
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
CONF_SECTION *_CONST conf
Module's instance configuration.
@ FR_TYPE_STRING
String of printable characters.
void * env_data
Per call environment data.
dl_module_inst_t const * inst
Dynamic loader API handle for the module.
dl_module_inst_t const * inst
Dynamic loader API handle for the module.
Temporary structure to hold arguments for module calls.
Temporary structure to hold arguments for instantiation calls.
Specifies a module method identifier.
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)
static int mod_bootstrap(module_inst_ctx_t const *mctx)
fr_value_box_t user_password
char const * name
name of this instance */
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)
@ MODULE_TYPE_THREAD_SAFE
Module is threadsafe.
#define MODULE_NAME_TERMINATOR
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)