2 Unix SMB/CIFS implementation.
3 Standardised Authentication types
4 Copyright (C) Andrew Bartlett 2001
5 Copyright (C) Stefan Metzmacher 2005
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 3 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "librpc/gen_ndr/ndr_krb5pac.h"
25 #include "librpc/gen_ndr/auth.h"
26 #include "../auth/common_auth.h"
28 extern const char *krbtgt_attrs[];
29 extern const char *server_attrs[];
30 extern const char *user_attrs[];
32 union netr_Validation;
33 struct netr_SamBaseInfo;
35 struct loadparm_context;
37 /* modules can use the following to determine if the interface has changed
38 * please increment the version number after each interface change
39 * with a comment and maybe update struct auth_critical_sizes.
41 /* version 1 - version from samba 3.0 - metze */
42 /* version 2 - initial samba4 version - metze */
43 /* version 3 - subsequent samba4 version - abartlet */
44 /* version 4 - subsequent samba4 version - metze */
45 /* version 0 - till samba4 is stable - metze */
46 #define AUTH4_INTERFACE_VERSION 0
48 #define AUTH_SESSION_INFO_DEFAULT_GROUPS 0x01 /* Add the user to the default world and network groups */
49 #define AUTH_SESSION_INFO_AUTHENTICATED 0x02 /* Add the user to the 'authenticated users' group */
50 #define AUTH_SESSION_INFO_SIMPLE_PRIVILEGES 0x04 /* Use a trivial map between users and privilages, rather than a DB */
51 #define AUTH_SESSION_INFO_UNIX_TOKEN 0x08 /* The returned token must have the unix_token and unix_info elements provided */
53 struct auth_method_context;
54 struct auth_check_password_request;
56 struct auth_session_info;
58 struct smb_krb5_context;
60 struct auth_operations {
63 /* If you are using this interface, then you are probably
64 * getting something wrong. This interface is only for
65 * security=server, and makes a number of compromises to allow
66 * that. It is not compatible with being a PDC. */
68 NTSTATUS (*get_challenge)(struct auth_method_context *ctx, TALLOC_CTX *mem_ctx, uint8_t chal[8]);
70 /* Given the user supplied info, check if this backend want to handle the password checking */
72 NTSTATUS (*want_check)(struct auth_method_context *ctx, TALLOC_CTX *mem_ctx,
73 const struct auth_usersupplied_info *user_info);
75 /* Given the user supplied info, check a password */
77 NTSTATUS (*check_password)(struct auth_method_context *ctx, TALLOC_CTX *mem_ctx,
78 const struct auth_usersupplied_info *user_info,
79 struct auth_user_info_dc **interim_info);
81 /* Lookup a 'session info interim' return based only on the principal or DN */
82 NTSTATUS (*get_user_info_dc_principal)(TALLOC_CTX *mem_ctx,
83 struct auth4_context *auth_context,
84 const char *principal,
85 struct ldb_dn *user_dn,
86 struct auth_user_info_dc **interim_info);
89 struct auth_method_context {
90 struct auth_method_context *prev, *next;
91 struct auth4_context *auth_ctx;
92 const struct auth_operations *ops;
97 /* this structure is used by backends to determine the size of some critical types */
98 struct auth_critical_sizes {
99 int interface_version;
100 int sizeof_auth_operations;
101 int sizeof_auth_methods;
102 int sizeof_auth_context;
103 int sizeof_auth_usersupplied_info;
104 int sizeof_auth_user_info_dc;
107 NTSTATUS encrypt_user_info(TALLOC_CTX *mem_ctx, struct auth4_context *auth_context,
108 enum auth_password_state to_state,
109 const struct auth_usersupplied_info *user_info_in,
110 const struct auth_usersupplied_info **user_info_encrypted);
113 #include "auth/session.h"
114 #include "auth/unix_token_proto.h"
115 #include "auth/system_session_proto.h"
116 #include "libcli/security/security.h"
120 struct gensec_security;
121 struct cli_credentials;
123 NTSTATUS auth_get_challenge(struct auth4_context *auth_ctx, uint8_t chal[8]);
124 NTSTATUS authsam_account_ok(TALLOC_CTX *mem_ctx,
125 struct ldb_context *sam_ctx,
126 uint32_t logon_parameters,
127 struct ldb_dn *domain_dn,
128 struct ldb_message *msg,
129 const char *logon_workstation,
130 const char *name_for_logs,
131 bool allow_domain_trust,
132 bool password_change);
134 struct auth_session_info *system_session(struct loadparm_context *lp_ctx);
135 NTSTATUS authsam_make_user_info_dc(TALLOC_CTX *mem_ctx, struct ldb_context *sam_ctx,
136 const char *netbios_name,
137 const char *domain_name,
138 struct ldb_dn *domain_dn,
139 struct ldb_message *msg,
140 DATA_BLOB user_sess_key, DATA_BLOB lm_sess_key,
141 struct auth_user_info_dc **_user_info_dc);
142 NTSTATUS auth_system_session_info(TALLOC_CTX *parent_ctx,
143 struct loadparm_context *lp_ctx,
144 struct auth_session_info **_session_info) ;
146 NTSTATUS auth_context_create_methods(TALLOC_CTX *mem_ctx, const char **methods,
147 struct tevent_context *ev,
148 struct imessaging_context *msg,
149 struct loadparm_context *lp_ctx,
150 struct ldb_context *sam_ctx,
151 struct auth4_context **auth_ctx);
152 const char **auth_methods_from_lp(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
154 NTSTATUS auth_context_create(TALLOC_CTX *mem_ctx,
155 struct tevent_context *ev,
156 struct imessaging_context *msg,
157 struct loadparm_context *lp_ctx,
158 struct auth4_context **auth_ctx);
160 NTSTATUS auth_check_password(struct auth4_context *auth_ctx,
162 const struct auth_usersupplied_info *user_info,
163 struct auth_user_info_dc **user_info_dc);
164 NTSTATUS auth4_init(void);
165 NTSTATUS auth_register(const struct auth_operations *ops);
166 NTSTATUS server_service_auth_init(void);
167 NTSTATUS authenticate_username_pw(TALLOC_CTX *mem_ctx,
168 struct tevent_context *ev,
169 struct imessaging_context *msg,
170 struct loadparm_context *lp_ctx,
171 const char *nt4_domain,
172 const char *nt4_username,
173 const char *password,
174 const uint32_t logon_parameters,
175 struct auth_session_info **session_info);
177 struct tevent_req *auth_check_password_send(TALLOC_CTX *mem_ctx,
178 struct tevent_context *ev,
179 struct auth4_context *auth_ctx,
180 const struct auth_usersupplied_info *user_info);
181 NTSTATUS auth_check_password_recv(struct tevent_req *req,
183 struct auth_user_info_dc **user_info_dc);
185 bool auth_challenge_may_be_modified(struct auth4_context *auth_ctx);
186 NTSTATUS auth_context_set_challenge(struct auth4_context *auth_ctx, const uint8_t chal[8], const char *set_by);
188 NTSTATUS auth_get_user_info_dc_principal(TALLOC_CTX *mem_ctx,
189 struct auth4_context *auth_ctx,
190 const char *principal,
191 struct ldb_dn *user_dn,
192 struct auth_user_info_dc **user_info_dc);
194 NTSTATUS samba_server_gensec_start(TALLOC_CTX *mem_ctx,
195 struct tevent_context *event_ctx,
196 struct imessaging_context *msg_ctx,
197 struct loadparm_context *lp_ctx,
198 struct cli_credentials *server_credentials,
199 const char *target_service,
200 struct gensec_security **gensec_context);
202 #endif /* _SMBAUTH_H_ */