r6498: Add comments in line with those I already added to 3.0.
[samba.git] / source / auth / auth.h
1 /* 
2    Unix SMB/CIFS implementation.
3    Standardised Authentication types
4    Copyright (C) Andrew Bartlett   2001
5    Copyright (C) Stefan Metzmacher 2005
6    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #ifndef _SAMBA_AUTH_H
23 #define _SAMBA_AUTH_H
24
25 #include "libcli/auth/credentials.h"
26 #include "auth/gensec/gensec.h"
27 #include "auth/gensec/spnego.h"
28
29 /* modules can use the following to determine if the interface has changed
30  * please increment the version number after each interface change
31  * with a comment and maybe update struct auth_critical_sizes.
32  */
33 /* version 1 - version from samba 3.0 - metze */
34 /* version 2 - initial samba4 version - metze */
35 /* version 3 - subsequent samba4 version - abartlet */
36 /* version 4 - subsequent samba4 version - metze */
37 #define AUTH_INTERFACE_VERSION 4
38
39 struct auth_usersupplied_info
40 {
41         const char *account_name;
42         const char *domain_name;
43         const char *workstation_name;
44
45         /* the values the client gives us */
46         struct {
47                 const char *account_name;
48                 const char *domain_name;
49         } client;
50
51         BOOL encrypted;
52
53         DATA_BLOB lm_resp;
54         DATA_BLOB nt_resp;
55         DATA_BLOB lm_interactive_password;
56         DATA_BLOB nt_interactive_password;
57         DATA_BLOB plaintext_password;
58 };
59
60 struct auth_serversupplied_info 
61 {
62         struct dom_sid *account_sid;
63         struct dom_sid *primary_group_sid;
64
65         size_t n_domain_groups;
66         struct dom_sid **domain_groups;
67
68         DATA_BLOB user_session_key;
69         DATA_BLOB lm_session_key;
70
71         const char *account_name;
72         const char *domain_name;
73
74         const char *full_name;
75         const char *logon_script;
76         const char *profile_path;
77         const char *home_directory;
78         const char *home_drive;
79         
80         NTTIME last_logon;
81         NTTIME last_logoff;
82         NTTIME acct_expiry;
83         NTTIME last_password_change;
84         NTTIME allow_password_change;
85         NTTIME force_password_change;
86
87         uint16_t logon_count;
88         uint16_t bad_password_count;
89
90         uint32_t acct_flags;
91
92         BOOL authenticated;
93 };
94
95 struct auth_session_info {
96         struct security_token *security_token;
97         struct auth_serversupplied_info *server_info;
98         DATA_BLOB session_key;
99 };
100
101 struct auth_method_context;
102
103 struct auth_operations {
104         const char *name;
105
106         /* If you are using this interface, then you are probably
107          * getting something wrong.  This interface is only for
108          * security=server, and makes a number of compromises to allow
109          * that.  It is not compatible with being a PDC.  */
110
111         NTSTATUS (*get_challenge)(struct auth_method_context *ctx, TALLOC_CTX *mem_ctx, DATA_BLOB *challenge);
112
113         /* Given the user supplied info, check a password */
114
115         NTSTATUS (*check_password)(struct auth_method_context *ctx, TALLOC_CTX *mem_ctx,
116                                    const struct auth_usersupplied_info *user_info,
117                                    struct auth_serversupplied_info **server_info);
118 };
119
120 struct auth_method_context {
121         struct auth_method_context *prev, *next;
122         struct auth_context *auth_ctx;
123         const struct auth_operations *ops;
124         int depth;
125         void *private_data;
126 };
127
128 struct auth_context {
129         struct {
130                 /* Who set this up in the first place? */ 
131                 const char *set_by;
132
133                 BOOL may_be_modified;
134
135                 DATA_BLOB data; 
136         } challenge;
137
138         /* methods, in the order they should be called */
139         struct auth_method_context *methods;
140 };
141
142 /* this structure is used by backends to determine the size of some critical types */
143 struct auth_critical_sizes {
144         int interface_version;
145         int sizeof_auth_operations;
146         int sizeof_auth_methods;
147         int sizeof_auth_context;
148         int sizeof_auth_usersupplied_info;
149         int sizeof_auth_serversupplied_info;
150         int sizeof_auth_str;
151 };
152
153 #endif /* _SMBAUTH_H_ */