summaryrefslogtreecommitdiffstats
path: root/auth/eurephia_authplugin_driver.h
blob: 02211d29c43ee2d1782c825162fc10cef2ab29e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*  eurephia_authplugin_driver.h
 *
 *  Copyright (C) 2013          David Sommerseth <dazo@users.sourceforge.net>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

/**
 * @file   eurephia_authplugin_driver.h
 * @author David Sommerseth <dazo@users.sourceforge.net>
 * @date   2013-02-15
 *
 * @brief  Authentication plug-in framework for eurephia
 */

#ifndef EUREPHIA_AUTHPLUGIN_DRIVER_H_
#define EUREPHIA_AUTHPLUGIN_DRIVER_H_

typedef enum { eAUTH_FAILED,     /**< Authentication failed */
               eAUTH_SUCCESS,    /**< Authentication successful */
               eAUTH_PLGERROR    /**< An error occured in the auth plug-in */
} eAuthResStatus;

/**
 *  Result type for authentication plug-ins
 */
typedef struct __eAuthResult {
        eAuthResStatus status;
        char *msg;
} eAuthResult;


/**
 *   Authentication plug-in API
 */
typedef struct __eAuthPlugin {
        /**
         *  Returns the API version of the authentication plug-in.  Used to
         *  ensure the core eurephia framework is compatible with the auth plug-in
         *
         *  @return An integer with the defined auth plug-in API level support.
         */
        unsigned int (*APIversion)();   // Mandatory

        /**
         *  Returns information about the authentication plug-in.  Used for
         *  informative log messages
         *
         */
        char * (*PluginInfo)();         // Mandatory

        /**
         * Mandatory auth plug-in function.  Authenticates a user account based
         * on the given username and password.
         *
         * @param eurephiaCTX*  Pointer to the current eurephia context
         * @param username*     String pointer to the username for the authentication
         * @param password*     String pointer to the password for the authentication
         *
         * @returns On success it returns a pointer to an eAuthResult struct, which
         *          contains further information on the success of the authentication.
         *          On system failure, NULL is returned.
         */
        eAuthResult * (*AuthenticateUser)(eurephiaCTX *ctx,
                                   const char *username,
                                   const char *password);

        /**
         *  ChangePassword() is only enabled if allowed by config and supported
         *  by (optionally) by the plug-in.  The eurephia context must be in
         *  an admin mode for this to be enabled.
         *
         * @param eurephiaCTX*  Pointer to the current eurephia context
         * @param username*     String pointer to the username account for the password change
         * @param oldpwd*       String pointer to the old password, for authentication
         * @param newpwd*       String pointer to the new password
         *
         * @returns On success it returns a pointer to an eAuthResult struct, which
         *          contains further information on the success of the authentication.
         *          On system failure, NULL is returned.
         */
        eAuthResult * (*ChangePassword)(eurephiaCTX *ctx,
                                 const char *username,
                                 const char *oldpwd,
                                 const char *newpwd);
} eAuthPlugin;

#endif /* EUREPHIA_AUTHPLUGIN_DRIVER_H_ */