2003-08-13 05:53:07 +04:00
/*
Unix SMB / CIFS implementation .
Standardised Authentication types
2005-01-09 15:55:25 +03:00
Copyright ( C ) Andrew Bartlett 2001
Copyright ( C ) Stefan Metzmacher 2005
2003-08-13 05:53:07 +04: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
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
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 .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
2004-02-03 14:10:56 +03:00
# ifndef _SAMBA_AUTH_H
# define _SAMBA_AUTH_H
2004-11-02 05:57:18 +03:00
# include "libcli/auth/credentials.h"
2005-03-29 12:24:03 +04:00
# include "auth/gensec/gensec.h"
# include "auth/gensec/spnego.h"
2006-04-27 23:50:13 +04:00
# include "lib/ldb/include/ldb.h"
2004-11-02 05:57:18 +03:00
2004-02-03 14:10:56 +03: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 12:45:00 +04:00
/* version 3 - subsequent samba4 version - abartlet */
2005-01-09 15:55:25 +03:00
/* version 4 - subsequent samba4 version - metze */
# define AUTH_INTERFACE_VERSION 4
2003-08-13 05:53:07 +04:00
2005-06-03 16:13:33 +04:00
# define USER_INFO_CASE_INSENSITIVE_USERNAME 0x01 /* username may be in any case */
# define USER_INFO_CASE_INSENSITIVE_PASSWORD 0x02 /* password may be in any case */
# define USER_INFO_DONT_CHECK_UNIX_ACCOUNT 0x04 /* dont check unix account status */
2005-10-28 15:20:48 +04:00
# define USER_INFO_INTERACTIVE_LOGON 0x08 /* dont check unix account status */
2005-06-03 16:13:33 +04:00
2005-07-22 08:10:07 +04:00
enum auth_password_state {
AUTH_PASSWORD_RESPONSE ,
AUTH_PASSWORD_HASH ,
AUTH_PASSWORD_PLAIN
} ;
2004-06-05 05:39:08 +04:00
struct auth_usersupplied_info
2003-08-13 05:53:07 +04:00
{
2005-01-09 15:55:25 +03:00
const char * workstation_name ;
2006-01-10 01:12:53 +03:00
struct socket_address * remote_host ;
2005-01-09 15:55:25 +03:00
2005-10-28 12:54:37 +04:00
uint32_t logon_parameters ;
2005-07-22 08:10:07 +04:00
BOOL mapped_state ;
2005-01-09 15:55:25 +03:00
/* the values the client gives us */
struct {
const char * account_name ;
const char * domain_name ;
2005-07-22 08:10:07 +04:00
} client , mapped ;
enum auth_password_state password_state ;
union {
struct {
DATA_BLOB lanman ;
DATA_BLOB nt ;
} response ;
struct {
struct samr_Password * lanman ;
struct samr_Password * nt ;
} hash ;
char * plaintext ;
} password ;
2005-06-03 16:13:33 +04:00
uint32_t flags ;
2004-06-05 05:39:08 +04:00
} ;
2003-08-13 05:53:07 +04:00
2004-06-05 05:39:08 +04:00
struct auth_serversupplied_info
2003-08-13 05:53:07 +04:00
{
2005-01-09 15:55:25 +03:00
struct dom_sid * account_sid ;
2004-06-05 05:39:08 +04:00
struct dom_sid * primary_group_sid ;
size_t n_domain_groups ;
struct dom_sid * * domain_groups ;
2005-01-09 15:55:25 +03:00
2004-05-02 12:45:00 +04:00
DATA_BLOB user_session_key ;
2003-12-14 13:45:50 +03:00
DATA_BLOB lm_session_key ;
2004-06-05 07:09:38 +04:00
2004-06-07 07:46:32 +04:00
const char * account_name ;
2005-01-09 15:55:25 +03:00
const char * domain_name ;
2004-06-07 07:46:32 +04:00
const char * full_name ;
const char * logon_script ;
const char * profile_path ;
const char * home_directory ;
const char * home_drive ;
2005-10-24 11:11:40 +04:00
const char * logon_server ;
2004-06-07 07:46:32 +04:00
NTTIME last_logon ;
NTTIME last_logoff ;
NTTIME acct_expiry ;
NTTIME last_password_change ;
NTTIME allow_password_change ;
NTTIME force_password_change ;
2005-01-09 15:55:25 +03:00
2005-01-31 19:06:21 +03:00
uint16_t logon_count ;
uint16_t bad_password_count ;
2005-01-09 15:55:25 +03:00
2005-01-31 19:06:21 +03:00
uint32_t acct_flags ;
2005-01-09 15:55:25 +03:00
BOOL authenticated ;
2004-06-05 05:39:08 +04:00
} ;
2004-12-11 08:41:19 +03:00
struct auth_session_info {
struct security_token * security_token ;
2004-06-05 05:39:08 +04:00
struct auth_serversupplied_info * server_info ;
DATA_BLOB session_key ;
2005-11-02 03:31:22 +03:00
struct cli_credentials * credentials ;
2004-06-05 05:39:08 +04:00
} ;
2003-08-13 05:53:07 +04:00
2005-01-09 15:55:25 +03:00
struct auth_method_context ;
2003-08-13 05:53:07 +04:00
2005-01-09 15:55:25 +03:00
struct auth_operations {
const char * name ;
2003-12-14 13:45:50 +03:00
2005-04-27 04:48:39 +04: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 . */
2005-01-09 15:55:25 +03:00
NTSTATUS ( * get_challenge ) ( struct auth_method_context * ctx , TALLOC_CTX * mem_ctx , DATA_BLOB * challenge ) ;
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 13:40:10 +04:00
2005-04-27 04:48:39 +04:00
/* Given the user supplied info, check a password */
2005-01-09 15:55:25 +03:00
NTSTATUS ( * check_password ) ( struct auth_method_context * ctx , TALLOC_CTX * mem_ctx ,
const struct auth_usersupplied_info * user_info ,
struct auth_serversupplied_info * * server_info ) ;
2003-08-13 05:53:07 +04:00
} ;
2005-01-09 15:55:25 +03:00
struct auth_method_context {
struct auth_method_context * prev , * next ;
struct auth_context * auth_ctx ;
const struct auth_operations * ops ;
int depth ;
2003-08-13 05:53:07 +04:00
void * private_data ;
2005-01-09 15:55:25 +03:00
} ;
2003-08-13 05:53:07 +04:00
2005-01-09 15:55:25 +03:00
struct auth_context {
struct {
/* Who set this up in the first place? */
const char * set_by ;
2004-05-02 12:45:00 +04:00
2005-01-09 15:55:25 +03:00
BOOL may_be_modified ;
2003-08-13 05:53:07 +04:00
2005-01-09 15:55:25 +03:00
DATA_BLOB data ;
} challenge ;
2004-02-03 14:10:56 +03:00
2005-01-09 15:55:25 +03:00
/* methods, in the order they should be called */
struct auth_method_context * methods ;
2005-06-16 15:36:09 +04:00
/* the event context to use for calls that can block */
struct event_context * event_ctx ;
2004-02-03 14:10:56 +03: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 ;
int sizeof_auth_serversupplied_info ;
} ;
2005-07-22 08:10:07 +04:00
NTSTATUS encrypt_user_info ( TALLOC_CTX * mem_ctx , struct auth_context * auth_context ,
enum auth_password_state to_state ,
const struct auth_usersupplied_info * user_info_in ,
const struct auth_usersupplied_info * * user_info_encrypted ) ;
2005-12-28 18:38:36 +03:00
# include "auth/auth_proto.h"
2005-07-22 08:10:07 +04:00
2004-05-02 12:45:00 +04:00
# endif /* _SMBAUTH_H_ */