~ubuntu-branches/ubuntu/precise/duo-unix/precise-proposed

« back to all changes in this revision

Viewing changes to lib/duo.h

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2011-04-15 13:16:33 UTC
  • Revision ID: james.westby@ubuntu.com-20110415131633-wa1gkjycigoafjmu
Tags: upstream-1.5
ImportĀ upstreamĀ versionĀ 1.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * duo.h
 
3
 *
 
4
 * Copyright (c) 2010 Duo Security
 
5
 * All rights reserved, all wrongs reversed.
 
6
 */
 
7
 
 
8
#ifndef DUO_H
 
9
#define DUO_H
 
10
 
 
11
#define DUO_API_HOST            "api.duosecurity.com"
 
12
 
 
13
typedef enum {
 
14
        DUO_OK = 0,                     /* great success! */
 
15
        DUO_FAIL,                       /* nice try */
 
16
        DUO_ABORT,                      /* give up */
 
17
        DUO_LIB_ERROR,                  /* unexpected library error */
 
18
        DUO_CONN_ERROR,                 /* problem connecting */
 
19
        DUO_CLIENT_ERROR,               /* you screwed up */
 
20
        DUO_SERVER_ERROR,               /* we screwed up */
 
21
} duo_code_t;
 
22
 
 
23
#define DUO_FLAG_SYNC   (1 << 0)        /* no incremental status reporting */
 
24
#define DUO_FLAG_AUTO   (1 << 1)        /* use default factor without prompt */
 
25
 
 
26
typedef struct duo_ctx duo_t;
 
27
 
 
28
/* Parse INI config file */
 
29
int         duo_parse_config(const char *filename, 
 
30
                int (*callback)(void *arg, const char *section,
 
31
                    const char *name, const char *val),
 
32
                void *arg);
 
33
 
 
34
/* Open Duo API handle */
 
35
duo_t      *duo_open(const char *ikey, const char *skey, const char *progname);
 
36
 
 
37
/* Override conversation prompt/status functions */
 
38
void        duo_set_conv_funcs(duo_t *d,
 
39
                char *(*conv_prompt)(void *conv_arg, const char *prompt,
 
40
                    char *buf, size_t bufsz),
 
41
                void (*conv_status)(void *conv_arg, const char *msg),
 
42
                void *conv_arg);
 
43
 
 
44
/* Override default host */
 
45
void        duo_set_host(duo_t *d, const char *hostname);
 
46
 
 
47
/* Override SSL verification */
 
48
void        duo_set_ssl_verify(duo_t *d, int bool);
 
49
 
 
50
/* Perform Duo authentication */
 
51
duo_code_t  duo_login(duo_t *d, const char *username,
 
52
                const char *client_ip, int flags);
 
53
 
 
54
/* Return error message from last API call */
 
55
const char *duo_geterr(duo_t *d);
 
56
 
 
57
/* Close API handle. */
 
58
void        duo_close(duo_t *d);
 
59
 
 
60
 
 
61
#endif /* DUO_H */