2 Unix SMB/CIFS implementation.
3 Process and provide the logged on user's authorization token
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/>.
21 #ifndef _SAMBA_AUTH_SESSION_H
22 #define _SAMBA_AUTH_SESSION_H
24 #include "lib/util/data_blob.h"
25 #include "librpc/gen_ndr/security.h"
26 #include "libcli/util/werror.h"
27 #include "lib/util/time.h"
28 #include "librpc/gen_ndr/netlogon.h"
29 #include "librpc/gen_ndr/auth.h"
31 struct loadparm_context
;
32 struct tevent_context
;
35 /* Create a security token for a session SYSTEM (the most
36 * trusted/privileged account), including the local machine account as
37 * the off-host credentials */
38 struct auth_session_info
*system_session(struct loadparm_context
*lp_ctx
) ;
40 enum claims_data_present
{
41 CLAIMS_DATA_ENCODED_CLAIMS_PRESENT
= 0x01,
42 CLAIMS_DATA_CLAIMS_PRESENT
= 0x02,
43 CLAIMS_DATA_SECURITY_CLAIMS_PRESENT
= 0x04,
47 DATA_BLOB encoded_claims_set
;
48 struct CLAIMS_SET
*claims_set
;
50 * These security claims are here treated as only a product — the result
51 * of conversion from another format — and ought not to be treated as
54 struct CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1
*security_claims
;
55 uint32_t n_security_claims
;
56 enum claims_data_present flags
;
60 struct claims_data
*user_claims
;
61 struct claims_data
*device_claims
;
64 NTSTATUS
auth_anonymous_user_info_dc(TALLOC_CTX
*mem_ctx
,
65 const char *netbios_name
,
66 struct auth_user_info_dc
**interim_info
);
67 NTSTATUS
auth_generate_security_token(TALLOC_CTX
*mem_ctx
,
68 struct loadparm_context
*lp_ctx
, /* Optional, if you don't want privileges */
69 struct ldb_context
*sam_ctx
, /* Optional, if you don't want local groups */
70 const struct auth_user_info_dc
*user_info_dc
,
71 const struct auth_user_info_dc
*device_info_dc
,
72 const struct auth_claims auth_claims
,
73 uint32_t session_info_flags
,
74 struct security_token
**_security_token
);
75 NTSTATUS
auth_generate_session_info(TALLOC_CTX
*mem_ctx
,
76 struct loadparm_context
*lp_ctx
, /* Optional, if you don't want privileges */
77 struct ldb_context
*sam_ctx
, /* Optional, if you don't want local groups */
78 const struct auth_user_info_dc
*user_info_dc
,
79 uint32_t session_info_flags
,
80 struct auth_session_info
**session_info
);
81 NTSTATUS
auth_anonymous_session_info(TALLOC_CTX
*parent_ctx
,
82 struct loadparm_context
*lp_ctx
,
83 struct auth_session_info
**session_info
);
84 struct auth_session_info
*auth_session_info_from_transport(TALLOC_CTX
*mem_ctx
,
85 struct auth_session_info_transport
*session_info_transport
,
86 struct loadparm_context
*lp_ctx
,
88 NTSTATUS
auth_session_info_transport_from_session(TALLOC_CTX
*mem_ctx
,
89 struct auth_session_info
*session_info
,
90 struct tevent_context
*event_ctx
,
91 struct loadparm_context
*lp_ctx
,
92 struct auth_session_info_transport
**transport_out
);
94 /* Produce a session_info for an arbitrary DN or principal in the local
95 * DB, assuming the local DB holds all the groups
97 * Supply either a principal or a DN
99 NTSTATUS
authsam_get_session_info_principal(TALLOC_CTX
*mem_ctx
,
100 struct loadparm_context
*lp_ctx
,
101 struct ldb_context
*sam_ctx
,
102 const char *principal
,
103 struct ldb_dn
*user_dn
,
104 uint32_t session_info_flags
,
105 struct auth_session_info
**session_info
);
107 struct auth_session_info
*anonymous_session(TALLOC_CTX
*mem_ctx
,
108 struct loadparm_context
*lp_ctx
);
110 struct auth_session_info
*admin_session(TALLOC_CTX
*mem_ctx
,
111 struct loadparm_context
*lp_ctx
,
112 struct dom_sid
*domain_sid
);
114 NTSTATUS
encode_claims_set(TALLOC_CTX
*mem_ctx
,
115 struct CLAIMS_SET
*claims_set
,
116 DATA_BLOB
*claims_blob
);
119 * Construct a ‘claims_data’ structure from a claims blob, such as is found in a
122 NTSTATUS
claims_data_from_encoded_claims_set(TALLOC_CTX
*claims_data_ctx
,
123 const DATA_BLOB
*encoded_claims_set
,
124 struct claims_data
**out
);
127 * Construct a ‘claims_data’ structure from a talloc‐allocated claims set, such
128 * as we might build from searching the database. If this function returns
129 * successfully, it assumes ownership of the claims set.
131 NTSTATUS
claims_data_from_claims_set(TALLOC_CTX
*claims_data_ctx
,
132 struct CLAIMS_SET
*claims_set
,
133 struct claims_data
**out
);
136 * From a ‘claims_data’ structure, return an encoded claims blob that can be put
139 NTSTATUS
claims_data_encoded_claims_set(TALLOC_CTX
*mem_ctx
,
140 struct claims_data
*claims_data
,
141 DATA_BLOB
*encoded_claims_set_out
);
144 * From a ‘claims_data’ structure, return an array of security claims that can
145 * be put in a security token for access checks.
147 NTSTATUS
claims_data_security_claims(TALLOC_CTX
*mem_ctx
,
148 struct claims_data
*claims_data
,
149 struct CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1
**security_claims_out
,
150 uint32_t *n_security_claims_out
);
152 #endif /* _SAMBA_AUTH_SESSION_H */