The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
rlm_yubikey.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This program is is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or (at
6  * your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16  */
17 #include <freeradius-devel/server/base.h>
18 #include <freeradius-devel/server/module_rlm.h>
19 #include <ctype.h>
20 
21 #include "config.h"
22 
23 #ifdef HAVE_YKCLIENT
24 #include <ykclient.h>
25 #endif
26 
27 #ifdef HAVE_YUBIKEY
28 #include <yubikey.h>
29 #endif
30 
31 #define YUBIKEY_TOKEN_LEN 32
32 
33 /*
34  * Define a structure for our module configuration.
35  *
36  * These variables do not need to be in a structure, but it's
37  * a lot cleaner to do so, and a pointer to the structure can
38  * be used as the instance handle.
39  */
40 typedef struct {
41  char const *name;
42  fr_dict_enum_value_t *auth_type; //!< Our Auth-Type.
43  unsigned int id_len; //!< The length of the Public ID portion of the OTP string.
44  bool split; //!< Split password string into components.
45  bool decrypt; //!< Decrypt the OTP string using the yubikey library.
46  bool validate; //!< Validate the OTP string using the ykclient library.
47  char const **uris; //!< Yubicloud URLs to validate the token against.
48 
49 #ifdef HAVE_YKCLIENT
50  unsigned int client_id; //!< Validation API client ID.
51  char const *api_key; //!< Validation API signing key.
52  ykclient_t *ykc; //!< ykclient configuration.
53  fr_pool_t *pool; //!< Connection pool instance.
54 #endif
56 
57 
58 /*
59  * decrypt.c - Decryption functions
60  */
62  request_t *request, char const *passcode);
63 
64 /*
65  * validate.c - Connection pool and validation functions
66  */
68 
70 
72  request_t *request, char const *passcode);
73 
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition: action.h:35
#define HIDDEN
Definition: build.h:312
A section grouping multiple CONF_PAIR.
Definition: cf_priv.h:89
Value of an enumerated attribute.
Definition: dict.h:209
Temporary structure to hold arguments for module calls.
Definition: module_ctx.h:41
A connection pool.
Definition: pool.c:85
static rs_t * conf
Definition: radsniff.c:53
rlm_rcode_t
Return codes indicating the result of the module call.
Definition: rcode.h:40
HIDDEN fr_dict_attr_t const * attr_yubikey_counter
Definition: rlm_yubikey.c:66
HIDDEN fr_dict_attr_t const * attr_auth_type
Definition: rlm_eap_peap.c:78
int rlm_yubikey_ykclient_init(CONF_SECTION *conf, rlm_yubikey_t *inst)
HIDDEN fr_dict_attr_t const * attr_yubikey_public_id
Definition: rlm_yubikey.c:64
char const ** uris
Yubicloud URLs to validate the token against.
Definition: rlm_yubikey.h:47
fr_dict_enum_value_t * auth_type
Our Auth-Type.
Definition: rlm_yubikey.h:42
HIDDEN fr_dict_attr_t const * attr_yubikey_key
Definition: rlm_yubikey.c:63
int rlm_yubikey_ykclient_detach(rlm_yubikey_t *inst)
HIDDEN fr_dict_attr_t const * attr_yubikey_private_id
Definition: rlm_yubikey.c:65
HIDDEN fr_dict_attr_t const * attr_yubikey_otp
Definition: rlm_yubikey.c:69
bool split
Split password string into components.
Definition: rlm_yubikey.h:44
HIDDEN fr_dict_attr_t const * attr_user_password
Definition: rlm_eap_fast.c:106
unsigned int id_len
The length of the Public ID portion of the OTP string.
Definition: rlm_yubikey.h:43
bool validate
Validate the OTP string using the ykclient library.
Definition: rlm_yubikey.h:46
unlang_action_t rlm_yubikey_decrypt(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request, char const *passcode)
bool decrypt
Decrypt the OTP string using the yubikey library.
Definition: rlm_yubikey.h:45
HIDDEN fr_dict_attr_t const * attr_yubikey_timestamp
Definition: rlm_yubikey.c:67
unlang_action_t rlm_yubikey_validate(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request, char const *passcode)
HIDDEN fr_dict_attr_t const * attr_yubikey_random
Definition: rlm_yubikey.c:68
char const * name
Definition: rlm_yubikey.h:41
eap_aka_sim_process_conf_t * inst