auth: provide private pointer and do not return original PAC signatures
[gd/samba-autobuild/.git] / auth / common_auth.h
1 /*
2    Unix SMB/CIFS implementation.
3    Standardised Authentication types
4    Copyright (C) Andrew Bartlett 2001-2010
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef AUTH_COMMON_AUTH_H
21 #define AUTH_COMMON_AUTH_H
22
23 #include "librpc/gen_ndr/auth.h"
24
25 #define USER_INFO_CASE_INSENSITIVE_USERNAME 0x01 /* username may be in any case */
26 #define USER_INFO_CASE_INSENSITIVE_PASSWORD 0x02 /* password may be in any case */
27 #define USER_INFO_DONT_CHECK_UNIX_ACCOUNT   0x04 /* don't check unix account status */
28 #define USER_INFO_INTERACTIVE_LOGON         0x08 /* don't check unix account status */
29
30 enum auth_password_state {
31         AUTH_PASSWORD_PLAIN = 1,
32         AUTH_PASSWORD_HASH = 2,
33         AUTH_PASSWORD_RESPONSE = 3
34 };
35
36 #define AUTH_SESSION_INFO_DEFAULT_GROUPS     0x01 /* Add the user to the default world and network groups */
37 #define AUTH_SESSION_INFO_AUTHENTICATED      0x02 /* Add the user to the 'authenticated users' group */
38 #define AUTH_SESSION_INFO_SIMPLE_PRIVILEGES  0x04 /* Use a trivial map between users and privilages, rather than a DB */
39 #define AUTH_SESSION_INFO_UNIX_TOKEN         0x08 /* The returned token must have the unix_token and unix_info elements provided */
40
41 struct auth_usersupplied_info
42 {
43         const char *workstation_name;
44         const struct tsocket_address *remote_host;
45
46         uint32_t logon_parameters;
47
48         bool mapped_state;
49         bool was_mapped;
50         /* the values the client gives us */
51         struct {
52                 const char *account_name;
53                 const char *domain_name;
54         } client, mapped;
55
56         enum auth_password_state password_state;
57
58         struct {
59                 struct {
60                         DATA_BLOB lanman;
61                         DATA_BLOB nt;
62                 } response;
63                 struct {
64                         struct samr_Password *lanman;
65                         struct samr_Password *nt;
66                 } hash;
67
68                 char *plaintext;
69         } password;
70         uint32_t flags;
71 };
72
73 struct auth_method_context;
74 struct tevent_context;
75 struct imessaging_context;
76 struct loadparm_context;
77 struct ldb_context;
78 struct smb_krb5_context;
79
80 struct auth4_context {
81         struct {
82                 /* Who set this up in the first place? */
83                 const char *set_by;
84
85                 bool may_be_modified;
86
87                 DATA_BLOB data;
88         } challenge;
89
90         /* methods, in the order they should be called */
91         struct auth_method_context *methods;
92
93         /* the event context to use for calls that can block */
94         struct tevent_context *event_ctx;
95
96         /* the messaging context which can be used by backends */
97         struct imessaging_context *msg_ctx;
98
99         /* loadparm context */
100         struct loadparm_context *lp_ctx;
101
102         /* SAM database for this local machine - to fill in local groups, or to authenticate local NTLM users */
103         struct ldb_context *sam_ctx;
104
105         /* Private data for the callbacks on this auth context */
106         void *private_data;
107
108         NTSTATUS (*check_password)(struct auth4_context *auth_ctx,
109                                    TALLOC_CTX *mem_ctx,
110                                    const struct auth_usersupplied_info *user_info,
111                                    struct auth_user_info_dc **user_info_dc);
112
113         NTSTATUS (*get_challenge)(struct auth4_context *auth_ctx, uint8_t chal[8]);
114
115         bool (*challenge_may_be_modified)(struct auth4_context *auth_ctx);
116
117         NTSTATUS (*set_challenge)(struct auth4_context *auth_ctx, const uint8_t chal[8], const char *set_by);
118
119         NTSTATUS (*generate_session_info)(TALLOC_CTX *mem_ctx,
120                                           struct auth4_context *auth_context,
121                                           struct auth_user_info_dc *user_info_dc,
122                                           uint32_t session_info_flags,
123                                           struct auth_session_info **session_info);
124
125         NTSTATUS (*generate_session_info_pac)(struct auth4_context *auth_ctx,
126                                               TALLOC_CTX *mem_ctx,
127                                               struct smb_krb5_context *smb_krb5_context,
128                                               DATA_BLOB *pac_blob,
129                                               const char *principal_name,
130                                               const struct tsocket_address *remote_address,
131                                               uint32_t session_info_flags,
132                                               struct auth_session_info **session_info);
133 };
134
135 #endif