-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.h
executable file
·115 lines (97 loc) · 2.68 KB
/
user.h
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/**
* @file
* User module header.
* @detail
* Represents an application user or user account. There is quite a lot of information that an
* application must store for each user in order to enforce security properly. There are also many rules that govern
* authentication and identity management.
* <P>
* A user account can be in one of several states. When first created, a User should be disabled, not expired, and
* unlocked. To start using the account, an administrator should enable the account. The account can be locked for a
* number of reasons, most commonly because they have failed login for too many times. Finally, the account can expire
* after the expiration date has been reached. The User must be enabled, not expired, and unlocked in order to pass
* authentication.
*
* @since January 30, 2011
*/
#include <stdlib.h>
#ifndef _USER_H_
#define _USER_H_
#define NAME_MAX 64
/**
* An application user account, including information required to enforce security on users properly.
*/
struct User_t {
long id;
char name[NAME_MAX];
char **roles;
int locked;
};
typedef struct User_t user;
/**
* Get the user id for the given user.
*
* @return A long integer representing a unique identifier for the given user,
* or -1 if the user is NULL.
*/
//extern long get_current_id(user *);
/**
* Set the current user of this application to the given user.
*/
//extern char *set_current_user(user *, const char *);
/**
* Clears the given user.
*/
//extern void init_user(user *);
/**
* @internal
* Adds the role to the user's list of roles.
*
* @asserts u is not null, role is not null
*/
//void add_role(user *u, char *role);
/**
* @internal
* Adds the roles to the user's list of roles.
*
* @asserts u is not null, roles is not null
*/
//void add_roles(user *u, char **roles);
/**
* @internal
* Removes the role passed in from the user's list of roles.
*/
//void remove_role(user *u, char *role);
/**
* @internal
* Checks if the user has the role specified.
*/
//int is_user_in_role(user *u, char *role);
/**
* @internal
* Adds the security event to the user's event list. It also
* takes action if it is detected to be above a threshold.
*
* @asserts u is not null, role is not null
*/
//void add_event(user *u, char *event);
/**
* @internal
* Changes the user's password to the password passed in. If the passwords
* don't match, then return fail.
*/
//int change_user_password(user *, char *new_passwd1, char *new_passwd2);
/**
* @internal
* Reset the user's password, and return the new password.
*/
//char *reset_password(user *);
/**
* Locks the user.
*/
int lock_user(user *u);
/**
* Unlocks the user.
*/
int unlock_user(user *u);
#endif /* _USER_H_ */