s3:auth Rename wksta_name -> workstation_name in auth_usersupplied_info
[samba.git] / source3 / include / auth.h
1 #ifndef _SMBAUTH_H_
2 #define _SMBAUTH_H_
3 /* 
4    Unix SMB/CIFS implementation.
5    Standardised Authentication types
6    Copyright (C) Andrew Bartlett 2001
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 struct auth_usersupplied_info {
23         DATA_BLOB lm_resp;
24         DATA_BLOB nt_resp;
25         DATA_BLOB lm_interactive_pwd;
26         DATA_BLOB nt_interactive_pwd;
27         DATA_BLOB plaintext_password;
28
29         bool encrypted;
30
31         bool was_mapped;              /* Did the username map actually match? */
32         char *client_domain;          /* domain name string */
33         char *domain;                 /* domain name after mapping */
34         char *internal_username;      /* username after mapping */
35         char *smb_name;               /* username before mapping */
36         const char *workstation_name; /* workstation name (netbios calling
37                                        * name) unicode string */
38
39         uint32 logon_parameters;
40
41 };
42
43 struct auth_serversupplied_info {
44         bool guest;
45         bool system;
46
47         struct dom_sid *sids;   /* These SIDs are preliminary between
48                            check_ntlm_password and the token creation. */
49         size_t num_sids;
50
51         struct unix_user_token utok;
52
53         /* NT group information taken from the info3 structure */
54
55         NT_USER_TOKEN *ptok;
56
57         /* This is the final session key, as used by SMB signing, and
58          * (truncated to 16 bytes) encryption on the SAMR and LSA pipes
59          * when over ncacn_np.
60          * It is calculated by NTLMSSP from the session key in the info3,
61          * and is  set from the Kerberos session key using
62          * krb5_auth_con_getremotesubkey().
63          *
64          * Bootom line, it is not the same as the session keys in info3.
65          */
66
67         DATA_BLOB user_session_key;
68         DATA_BLOB lm_session_key;
69
70         struct netr_SamInfo3 *info3;
71
72         void *pam_handle;
73
74         /*
75          * This is a token from /etc/passwd and /etc/group
76          */
77         bool nss_token;
78
79         char *unix_name;
80
81         /*
82          * For performance reasons we keep an alpha_strcpy-sanitized version
83          * of the username around as long as the global variable current_user
84          * still exists. If we did not do keep this, we'd have to call
85          * alpha_strcpy whenever we do a become_user(), potentially on every
86          * smb request. See set_current_user_info.
87          */
88         char *sanitized_username;
89 };
90
91 struct auth_context {
92         DATA_BLOB challenge; 
93
94         /* Who set this up in the first place? */ 
95         const char *challenge_set_by; 
96
97         bool challenge_may_be_modified;
98
99         struct auth_methods *challenge_set_method; 
100         /* What order are the various methods in?   Try to stop it changing under us */ 
101         struct auth_methods *auth_method_list;  
102
103         NTSTATUS (*get_ntlm_challenge)(struct auth_context *auth_context,
104                                        uint8_t chal[8]);
105         NTSTATUS (*check_ntlm_password)(const struct auth_context *auth_context,
106                                         const struct auth_usersupplied_info *user_info, 
107                                         struct auth_serversupplied_info **server_info);
108         NTSTATUS (*nt_status_squash)(NTSTATUS nt_status);
109         void (*free)(struct auth_context **auth_context);
110 };
111
112 typedef struct auth_methods
113 {
114         struct auth_methods *prev, *next;
115         const char *name; /* What name got this module */
116
117         NTSTATUS (*auth)(const struct auth_context *auth_context,
118                          void *my_private_data, 
119                          TALLOC_CTX *mem_ctx,
120                          const struct auth_usersupplied_info *user_info, 
121                          struct auth_serversupplied_info **server_info);
122
123         /* If you are using this interface, then you are probably
124          * getting something wrong.  This interface is only for
125          * security=server, and makes a number of compromises to allow
126          * that.  It is not compatible with being a PDC.  */
127         DATA_BLOB (*get_chal)(const struct auth_context *auth_context,
128                               void **my_private_data, 
129                               TALLOC_CTX *mem_ctx);
130
131         /* Used to keep tabs on things like the cli for SMB server authentication */
132         void *private_data;
133
134 } auth_methods;
135
136 typedef NTSTATUS (*auth_init_function)(struct auth_context *, const char *, struct auth_methods **);
137
138 struct auth_init_function_entry {
139         const char *name;
140         /* Function to create a member of the authmethods list */
141
142         auth_init_function init;
143
144         struct auth_init_function_entry *prev, *next;
145 };
146
147 struct auth_ntlmssp_state;
148
149 /* Changed from 1 -> 2 to add the logon_parameters field. */
150 #define AUTH_INTERFACE_VERSION 2
151
152 #endif /* _SMBAUTH_H_ */