r4620: - add interface functions to the auth subsystem so that callers doesn't need to
[kai/samba.git] / source4 / 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/ntlmssp.h"
26 #include "libcli/auth/credentials.h"
27 #include "libcli/auth/gensec.h"
28 #include "libcli/auth/spnego.h"
29
30 /* modules can use the following to determine if the interface has changed
31  * please increment the version number after each interface change
32  * with a comment and maybe update struct auth_critical_sizes.
33  */
34 /* version 1 - version from samba 3.0 - metze */
35 /* version 2 - initial samba4 version - metze */
36 /* version 3 - subsequent samba4 version - abartlet */
37 /* version 4 - subsequent samba4 version - metze */
38 #define AUTH_INTERFACE_VERSION 4
39
40 struct auth_usersupplied_info
41 {
42         const char *account_name;
43         const char *domain_name;
44         const char *workstation_name;
45
46         /* the values the client gives us */
47         struct {
48                 const char *account_name;
49                 const char *domain_name;
50         } client;
51
52         BOOL encrypted;
53
54         DATA_BLOB lm_resp;
55         DATA_BLOB nt_resp;
56         DATA_BLOB lm_interactive_password;
57         DATA_BLOB nt_interactive_password;
58         DATA_BLOB plaintext_password;
59 };
60
61 struct auth_serversupplied_info 
62 {
63         struct dom_sid *account_sid;
64         struct dom_sid *primary_group_sid;
65
66         size_t n_domain_groups;
67         struct dom_sid **domain_groups;
68
69         DATA_BLOB user_session_key;
70         DATA_BLOB lm_session_key;
71
72         const char *account_name;
73         const char *domain_name;
74
75         const char *full_name;
76         const char *logon_script;
77         const char *profile_path;
78         const char *home_directory;
79         const char *home_drive;
80         
81         NTTIME last_logon;
82         NTTIME last_logoff;
83         NTTIME acct_expiry;
84         NTTIME last_password_change;
85         NTTIME allow_password_change;
86         NTTIME force_password_change;
87
88         uint16 logon_count;
89         uint16 bad_password_count;
90
91         uint32 acct_flags;
92
93         BOOL authenticated;
94 };
95
96 struct auth_session_info {
97         struct security_token *security_token;
98         struct auth_serversupplied_info *server_info;
99         DATA_BLOB session_key;
100 };
101
102 struct auth_method_context;
103
104 struct auth_operations {
105         const char *name;
106
107         NTSTATUS (*get_challenge)(struct auth_method_context *ctx, TALLOC_CTX *mem_ctx, DATA_BLOB *challenge);
108
109         NTSTATUS (*check_password)(struct auth_method_context *ctx, TALLOC_CTX *mem_ctx,
110                                    const struct auth_usersupplied_info *user_info,
111                                    struct auth_serversupplied_info **server_info);
112 };
113
114 struct auth_method_context {
115         struct auth_method_context *prev, *next;
116         struct auth_context *auth_ctx;
117         const struct auth_operations *ops;
118         int depth;
119         void *private_data;
120 };
121
122 struct auth_context {
123         struct {
124                 /* Who set this up in the first place? */ 
125                 const char *set_by;
126
127                 BOOL may_be_modified;
128
129                 DATA_BLOB data; 
130         } challenge;
131
132         /* methods, in the order they should be called */
133         struct auth_method_context *methods;
134 };
135
136 /* this structure is used by backends to determine the size of some critical types */
137 struct auth_critical_sizes {
138         int interface_version;
139         int sizeof_auth_operations;
140         int sizeof_auth_methods;
141         int sizeof_auth_context;
142         int sizeof_auth_usersupplied_info;
143         int sizeof_auth_serversupplied_info;
144         int sizeof_auth_str;
145 };
146
147 #endif /* _SMBAUTH_H_ */