2 Unix SMB/CIFS implementation.
4 SASL/EXTERNAL authentication.
6 Copyright (C) Howard Chu <hyc@symas.com> 2013
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "lib/util/tevent_ntstatus.h"
25 #include "auth/credentials/credentials.h"
26 #include "auth/gensec/gensec.h"
27 #include "auth/gensec/gensec_internal.h"
28 #include "auth/gensec/gensec_proto.h"
29 #include "auth/gensec/gensec_toplevel_proto.h"
32 #define DBGC_CLASS DBGC_AUTH
34 /* SASL/EXTERNAL is essentially a no-op; it is only usable when the transport
35 * layer is already mutually authenticated.
38 NTSTATUS
gensec_external_init(TALLOC_CTX
*ctx
);
40 static NTSTATUS
gensec_external_start(struct gensec_security
*gensec_security
)
42 if (gensec_security
->want_features
& GENSEC_FEATURE_SIGN
)
43 return NT_STATUS_INVALID_PARAMETER
;
44 if (gensec_security
->want_features
& GENSEC_FEATURE_SEAL
)
45 return NT_STATUS_INVALID_PARAMETER
;
50 struct gensec_external_update_state
{
54 static struct tevent_req
*gensec_external_update_send(TALLOC_CTX
*mem_ctx
,
55 struct tevent_context
*ev
,
56 struct gensec_security
*gensec_security
,
59 struct tevent_req
*req
;
60 struct gensec_external_update_state
*state
= NULL
;
62 req
= tevent_req_create(mem_ctx
, &state
,
63 struct gensec_external_update_state
);
68 state
->out
= data_blob_talloc(state
, "", 0);
69 if (tevent_req_nomem(state
->out
.data
, req
)) {
70 return tevent_req_post(req
, ev
);
74 return tevent_req_post(req
, ev
);
77 static NTSTATUS
gensec_external_update_recv(struct tevent_req
*req
,
78 TALLOC_CTX
*out_mem_ctx
,
81 struct gensec_external_update_state
*state
=
83 struct gensec_external_update_state
);
86 *out
= data_blob_null
;
88 if (tevent_req_is_nterror(req
, &status
)) {
89 tevent_req_received(req
);
94 tevent_req_received(req
);
98 /* We have no features */
99 static bool gensec_external_have_feature(struct gensec_security
*gensec_security
,
105 static const struct gensec_security_ops gensec_external_ops
= {
106 .name
= "sasl-EXTERNAL",
107 .sasl_name
= "EXTERNAL",
108 .client_start
= gensec_external_start
,
109 .update_send
= gensec_external_update_send
,
110 .update_recv
= gensec_external_update_recv
,
111 .have_feature
= gensec_external_have_feature
,
113 .priority
= GENSEC_EXTERNAL
117 NTSTATUS
gensec_external_init(TALLOC_CTX
*ctx
)
121 ret
= gensec_register(ctx
, &gensec_external_ops
);
122 if (!NT_STATUS_IS_OK(ret
)) {
123 DEBUG(0,("Failed to register '%s' gensec backend!\n",
124 gensec_external_ops
.name
));