2010-01-12 11:05:16 -05:00
/*
2003-08-13 01:53:07 +00:00
Unix SMB / CIFS implementation .
Standardised Authentication types
2005-01-09 12:55:25 +00:00
Copyright ( C ) Andrew Bartlett 2001
Copyright ( C ) Stefan Metzmacher 2005
2010-01-12 11:05:16 -05:00
2003-08-13 01:53:07 +00:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 02:07:03 +00:00
the Free Software Foundation ; either version 3 of the License , or
2003-08-13 01:53:07 +00:00
( at your option ) any later version .
2010-01-12 11:05:16 -05:00
2003-08-13 01:53:07 +00:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2010-01-12 11:05:16 -05:00
2003-08-13 01:53:07 +00:00
You should have received a copy of the GNU General Public License
2007-07-10 02:07:03 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-08-13 01:53:07 +00:00
*/
2004-02-03 11:10:56 +00:00
# ifndef _SAMBA_AUTH_H
# define _SAMBA_AUTH_H
2008-08-28 16:28:47 +10:00
# include "librpc/gen_ndr/ndr_krb5pac.h"
2011-02-08 16:39:34 +11:00
# include "librpc/gen_ndr/auth.h"
2010-05-04 16:44:08 +10:00
# include "../auth/common_auth.h"
2008-08-28 16:28:47 +10:00
2009-07-16 17:37:36 +10:00
extern const char * krbtgt_attrs [ ] ;
extern const char * server_attrs [ ] ;
2007-07-27 06:31:12 +00:00
extern const char * user_attrs [ ] ;
2006-11-07 00:48:36 +00:00
union netr_Validation ;
2006-11-07 12:42:51 +00:00
struct netr_SamBaseInfo ;
struct netr_SamInfo3 ;
2007-12-02 16:20:18 +01:00
struct loadparm_context ;
2004-11-02 02:57:18 +00:00
2004-02-03 11:10:56 +00:00
/* modules can use the following to determine if the interface has changed
* please increment the version number after each interface change
* with a comment and maybe update struct auth_critical_sizes .
*/
/* version 1 - version from samba 3.0 - metze */
/* version 2 - initial samba4 version - metze */
2004-05-02 08:45:00 +00:00
/* version 3 - subsequent samba4 version - abartlet */
2005-01-09 12:55:25 +00:00
/* version 4 - subsequent samba4 version - metze */
2006-07-27 11:24:18 +00:00
/* version 0 - till samba4 is stable - metze */
2011-05-07 08:14:06 +02:00
# define AUTH4_INTERFACE_VERSION 0
2003-08-13 01:53:07 +00:00
2010-12-21 11:43:04 +11:00
# define AUTH_SESSION_INFO_DEFAULT_GROUPS 0x01 /* Add the user to the default world and network groups */
# define AUTH_SESSION_INFO_AUTHENTICATED 0x02 /* Add the user to the 'authenticated users' group */
# define AUTH_SESSION_INFO_SIMPLE_PRIVILEGES 0x04 /* Use a trivial map between users and privilages, rather than a DB */
2011-07-21 15:39:27 +10:00
# define AUTH_SESSION_INFO_UNIX_TOKEN 0x08 /* The returned token must have the unix_token and unix_info elements provided */
2010-04-19 15:51:57 +10:00
2005-01-09 12:55:25 +00:00
struct auth_method_context ;
2006-07-27 13:02:27 +00:00
struct auth_check_password_request ;
2011-05-07 08:14:06 +02:00
struct auth4_context ;
2010-04-13 12:00:06 +10:00
struct auth_session_info ;
2010-04-15 11:58:05 +10:00
struct ldb_dn ;
2003-08-13 01:53:07 +00:00
2005-01-09 12:55:25 +00:00
struct auth_operations {
const char * name ;
2003-12-14 10:45:50 +00:00
2005-04-27 00:48:39 +00:00
/* If you are using this interface, then you are probably
* getting something wrong . This interface is only for
* security = server , and makes a number of compromises to allow
* that . It is not compatible with being a PDC . */
2009-12-14 20:32:47 +11:00
NTSTATUS ( * get_challenge ) ( struct auth_method_context * ctx , TALLOC_CTX * mem_ctx , uint8_t chal [ 8 ] ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 09:40:10 +00:00
2006-07-27 11:24:18 +00:00
/* Given the user supplied info, check if this backend want to handle the password checking */
NTSTATUS ( * want_check ) ( struct auth_method_context * ctx , TALLOC_CTX * mem_ctx ,
const struct auth_usersupplied_info * user_info ) ;
2005-04-27 00:48:39 +00:00
/* Given the user supplied info, check a password */
2005-01-09 12:55:25 +00:00
NTSTATUS ( * check_password ) ( struct auth_method_context * ctx , TALLOC_CTX * mem_ctx ,
const struct auth_usersupplied_info * user_info ,
2011-02-08 16:53:13 +11:00
struct auth_user_info_dc * * interim_info ) ;
/* Lookup a 'session info interim' return based only on the principal or DN */
NTSTATUS ( * get_user_info_dc_principal ) ( TALLOC_CTX * mem_ctx ,
2011-05-07 08:14:06 +02:00
struct auth4_context * auth_context ,
2011-02-08 16:53:13 +11:00
const char * principal ,
struct ldb_dn * user_dn ,
struct auth_user_info_dc * * interim_info ) ;
2003-08-13 01:53:07 +00:00
} ;
2005-01-09 12:55:25 +00:00
struct auth_method_context {
struct auth_method_context * prev , * next ;
2011-05-07 08:14:06 +02:00
struct auth4_context * auth_ctx ;
2005-01-09 12:55:25 +00:00
const struct auth_operations * ops ;
int depth ;
2003-08-13 01:53:07 +00:00
void * private_data ;
2005-01-09 12:55:25 +00:00
} ;
2003-08-13 01:53:07 +00:00
2011-05-07 08:14:06 +02:00
struct auth4_context {
2005-01-09 12:55:25 +00:00
struct {
2010-01-12 11:05:16 -05:00
/* Who set this up in the first place? */
2005-01-09 12:55:25 +00:00
const char * set_by ;
2004-05-02 08:45:00 +00:00
2007-08-27 18:10:19 +00:00
bool may_be_modified ;
2003-08-13 01:53:07 +00:00
2010-01-12 11:05:16 -05:00
DATA_BLOB data ;
2005-01-09 12:55:25 +00:00
} challenge ;
2004-02-03 11:10:56 +00:00
2005-01-09 12:55:25 +00:00
/* methods, in the order they should be called */
struct auth_method_context * methods ;
2005-06-16 11:36:09 +00:00
/* the event context to use for calls that can block */
2008-12-29 20:24:57 +01:00
struct tevent_context * event_ctx ;
2006-07-31 14:05:08 +00:00
/* the messaging context which can be used by backends */
2011-05-03 10:40:33 +10:00
struct imessaging_context * msg_ctx ;
2007-12-02 17:56:09 +01:00
/* loadparm context */
struct loadparm_context * lp_ctx ;
2009-02-13 10:24:16 +11:00
2010-04-13 12:00:06 +10:00
/* SAM database for this local machine - to fill in local groups, or to authenticate local NTLM users */
struct ldb_context * sam_ctx ;
2011-05-07 08:14:06 +02:00
NTSTATUS ( * check_password ) ( struct auth4_context * auth_ctx ,
2009-02-13 10:24:16 +11:00
TALLOC_CTX * mem_ctx ,
2010-01-12 11:05:16 -05:00
const struct auth_usersupplied_info * user_info ,
2011-02-08 16:53:13 +11:00
struct auth_user_info_dc * * user_info_dc ) ;
2010-01-12 11:05:16 -05:00
2011-05-07 08:14:06 +02:00
NTSTATUS ( * get_challenge ) ( struct auth4_context * auth_ctx , uint8_t chal [ 8 ] ) ;
2009-02-13 10:24:16 +11:00
2011-05-07 08:14:06 +02:00
bool ( * challenge_may_be_modified ) ( struct auth4_context * auth_ctx ) ;
2009-02-13 10:24:16 +11:00
2011-05-07 08:14:06 +02:00
NTSTATUS ( * set_challenge ) ( struct auth4_context * auth_ctx , const uint8_t chal [ 8 ] , const char * set_by ) ;
2010-01-12 11:05:16 -05:00
2011-02-08 16:53:13 +11:00
NTSTATUS ( * get_user_info_dc_principal ) ( TALLOC_CTX * mem_ctx ,
2011-05-07 08:14:06 +02:00
struct auth4_context * auth_ctx ,
2011-02-08 16:53:13 +11:00
const char * principal ,
struct ldb_dn * user_dn ,
struct auth_user_info_dc * * user_info_dc ) ;
2009-02-13 10:24:16 +11:00
2010-04-13 12:00:06 +10:00
NTSTATUS ( * generate_session_info ) ( TALLOC_CTX * mem_ctx ,
2011-05-07 08:14:06 +02:00
struct auth4_context * auth_context ,
2011-02-08 16:53:13 +11:00
struct auth_user_info_dc * user_info_dc ,
2010-04-19 15:51:57 +10:00
uint32_t session_info_flags ,
2010-04-13 12:00:06 +10:00
struct auth_session_info * * session_info ) ;
2004-02-03 11:10:56 +00:00
} ;
/* this structure is used by backends to determine the size of some critical types */
struct auth_critical_sizes {
int interface_version ;
int sizeof_auth_operations ;
int sizeof_auth_methods ;
int sizeof_auth_context ;
int sizeof_auth_usersupplied_info ;
2011-02-08 16:53:13 +11:00
int sizeof_auth_user_info_dc ;
2004-02-03 11:10:56 +00:00
} ;
2011-05-07 08:14:06 +02:00
NTSTATUS encrypt_user_info ( TALLOC_CTX * mem_ctx , struct auth4_context * auth_context ,
2005-07-22 04:10:07 +00:00
enum auth_password_state to_state ,
const struct auth_usersupplied_info * user_info_in ,
const struct auth_usersupplied_info * * user_info_encrypted ) ;
2011-07-21 17:06:17 +10:00
struct wbc_context ;
2007-11-26 02:25:20 +01:00
# include "auth/session.h"
2011-07-21 17:06:17 +10:00
# include "auth/unix_token_proto.h"
2007-11-26 02:25:20 +01:00
# include "auth/system_session_proto.h"
2011-03-14 11:01:47 -04:00
# include "libcli/security/security.h"
2008-04-02 04:53:27 +02:00
struct ldb_message ;
struct ldb_context ;
2009-02-13 10:24:16 +11:00
struct gensec_security ;
2011-02-10 20:21:11 +11:00
struct cli_credentials ;
2009-02-13 10:24:16 +11:00
2011-05-07 08:14:06 +02:00
NTSTATUS auth_get_challenge ( struct auth4_context * auth_ctx , uint8_t chal [ 8 ] ) ;
2008-04-02 04:53:27 +02:00
NTSTATUS authsam_account_ok ( TALLOC_CTX * mem_ctx ,
struct ldb_context * sam_ctx ,
uint32_t logon_parameters ,
2009-05-26 12:31:39 +10:00
struct ldb_dn * domain_dn ,
2008-04-02 04:53:27 +02:00
struct ldb_message * msg ,
const char * logon_workstation ,
2008-12-04 15:09:21 +01:00
const char * name_for_logs ,
2009-06-18 11:08:46 +10:00
bool allow_domain_trust ,
bool password_change ) ;
2011-05-07 00:49:38 +10:00
2010-04-13 22:11:26 +10:00
struct auth_session_info * system_session ( struct loadparm_context * lp_ctx ) ;
2011-02-08 16:53:13 +11:00
NTSTATUS authsam_make_user_info_dc ( TALLOC_CTX * mem_ctx , struct ldb_context * sam_ctx ,
2008-04-02 04:53:27 +02:00
const char * netbios_name ,
2009-05-26 12:31:39 +10:00
const char * domain_name ,
2010-01-12 11:05:16 -05:00
struct ldb_dn * domain_dn ,
2008-04-02 04:53:27 +02:00
struct ldb_message * msg ,
DATA_BLOB user_sess_key , DATA_BLOB lm_sess_key ,
2011-02-08 16:53:13 +11:00
struct auth_user_info_dc * * _user_info_dc ) ;
2010-01-12 11:05:16 -05:00
NTSTATUS auth_system_session_info ( TALLOC_CTX * parent_ctx ,
2008-04-02 04:53:27 +02:00
struct loadparm_context * lp_ctx ,
struct auth_session_info * * _session_info ) ;
2010-01-12 11:05:16 -05:00
NTSTATUS auth_context_create_methods ( TALLOC_CTX * mem_ctx , const char * * methods ,
2008-12-29 20:24:57 +01:00
struct tevent_context * ev ,
2011-05-03 10:40:33 +10:00
struct imessaging_context * msg ,
2008-04-02 04:53:27 +02:00
struct loadparm_context * lp_ctx ,
2010-04-15 11:58:05 +10:00
struct ldb_context * sam_ctx ,
2011-05-07 08:14:06 +02:00
struct auth4_context * * auth_ctx ) ;
2011-01-18 19:13:19 +11:00
const char * * auth_methods_from_lp ( TALLOC_CTX * mem_ctx , struct loadparm_context * lp_ctx ) ;
2008-04-02 04:53:27 +02:00
2010-01-12 11:05:16 -05:00
NTSTATUS auth_context_create ( TALLOC_CTX * mem_ctx ,
2008-12-29 20:24:57 +01:00
struct tevent_context * ev ,
2011-05-03 10:40:33 +10:00
struct imessaging_context * msg ,
2008-04-02 04:53:27 +02:00
struct loadparm_context * lp_ctx ,
2011-05-07 08:14:06 +02:00
struct auth4_context * * auth_ctx ) ;
NTSTATUS auth_context_create_from_ldb ( TALLOC_CTX * mem_ctx , struct ldb_context * ldb , struct auth4_context * * auth_ctx ) ;
2008-04-02 04:53:27 +02:00
2011-05-07 08:14:06 +02:00
NTSTATUS auth_check_password ( struct auth4_context * auth_ctx ,
2008-04-02 04:53:27 +02:00
TALLOC_CTX * mem_ctx ,
2010-01-12 11:05:16 -05:00
const struct auth_usersupplied_info * user_info ,
2011-02-08 16:53:13 +11:00
struct auth_user_info_dc * * user_info_dc ) ;
2011-02-15 16:30:35 +11:00
NTSTATUS auth4_init ( void ) ;
2008-04-02 04:53:27 +02:00
NTSTATUS auth_register ( const struct auth_operations * ops ) ;
2010-04-16 08:42:12 +10:00
NTSTATUS server_service_auth_init ( void ) ;
2008-04-02 04:53:27 +02:00
NTSTATUS authenticate_username_pw ( TALLOC_CTX * mem_ctx ,
2010-11-05 00:00:13 +02:00
struct tevent_context * ev ,
2011-05-03 10:40:33 +10:00
struct imessaging_context * msg ,
2010-11-05 00:00:13 +02:00
struct loadparm_context * lp_ctx ,
const char * nt4_domain ,
const char * nt4_username ,
const char * password ,
const uint32_t logon_parameters ,
struct auth_session_info * * session_info ) ;
2009-12-23 09:09:37 +01:00
struct tevent_req * auth_check_password_send ( TALLOC_CTX * mem_ctx ,
struct tevent_context * ev ,
2011-05-07 08:14:06 +02:00
struct auth4_context * auth_ctx ,
2009-12-23 09:09:37 +01:00
const struct auth_usersupplied_info * user_info ) ;
NTSTATUS auth_check_password_recv ( struct tevent_req * req ,
2008-04-02 04:53:27 +02:00
TALLOC_CTX * mem_ctx ,
2011-02-08 16:53:13 +11:00
struct auth_user_info_dc * * user_info_dc ) ;
2008-04-02 04:53:27 +02:00
2011-05-07 08:14:06 +02:00
bool auth_challenge_may_be_modified ( struct auth4_context * auth_ctx ) ;
NTSTATUS auth_context_set_challenge ( struct auth4_context * auth_ctx , const uint8_t chal [ 8 ] , const char * set_by ) ;
2005-07-22 04:10:07 +00:00
2011-02-08 16:53:13 +11:00
NTSTATUS auth_get_user_info_dc_principal ( TALLOC_CTX * mem_ctx ,
2011-05-07 08:14:06 +02:00
struct auth4_context * auth_ctx ,
2009-12-29 11:50:46 +01:00
const char * principal ,
2010-04-15 11:58:05 +10:00
struct ldb_dn * user_dn ,
2011-02-08 16:53:13 +11:00
struct auth_user_info_dc * * user_info_dc ) ;
2009-12-29 11:50:46 +01:00
2009-02-13 10:24:16 +11:00
NTSTATUS samba_server_gensec_start ( TALLOC_CTX * mem_ctx ,
struct tevent_context * event_ctx ,
2011-05-03 10:40:33 +10:00
struct imessaging_context * msg_ctx ,
2009-02-13 10:24:16 +11:00
struct loadparm_context * lp_ctx ,
struct cli_credentials * server_credentials ,
const char * target_service ,
struct gensec_security * * gensec_context ) ;
2004-05-02 08:45:00 +00:00
# endif /* _SMBAUTH_H_ */