25RCSID(
"$Id: c3d5f06ba86ca2936ee692b9a3852919328bf267 $")
27#include <freeradius-devel/server/base.h>
28#include <freeradius-devel/server/module_rlm.h>
29#include <freeradius-devel/util/base32.h>
45 .pair.dflt =
"control.TOTP.Secret", .pair.dflt_quote =
T_BARE_WORD },
48 .pair.dflt =
"control.TOTP.key", .pair.dflt_quote =
T_BARE_WORD },
51 .pair.dflt =
"request.TOTP.From-User", .pair.dflt_quote =
T_BARE_WORD },
92 if (user_password->vb_length == 0) {
93 RWARN(
"TOTP.From-User is empty");
97 if (user_password->vb_length !=
inst->totp.otp_length) {
98 RWARN(
"TOTP.From-User has incorrect length. Expected %u, got %zu",
99 inst->totp.otp_length, user_password->vb_length);
107 our_key = key->vb_octets;
108 our_keylen = key->vb_length;
117 RERROR(
"TOTP.Secret cannot be decoded");
131 switch (
fr_totp_cmp(&
inst->totp, request, now, our_key, our_keylen, user_password->vb_strvalue)) {
170 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_parser_t const * env
Parsing rules for call method env.
@ CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE
bare words are treated as an attribute, but strings may be xlats.
@ 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.
@ FR_TYPE_INT32
32 Bit signed integer.
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_UNLANG_FAIL
#define RETURN_UNLANG_REJECT
#define RETURN_UNLANG_NOOP
fr_value_box_t time_offset
static const call_env_method_t method_env
fr_value_box_t user_password
static unlang_action_t mod_authenticate(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
static const conf_parser_t module_config[]
static int mod_instantiate(module_inst_ctx_t const *mctx)
#define FR_SBUFF_IN(_start, _len_or_end)
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
size_t inst_size
Size of the module's instance data.
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).
static fr_time_delta_t time_offset
#define fr_type_is_null(_x)