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"
31 /* SASL/EXTERNAL is essentially a no-op; it is only usable when the transport
32 * layer is already mutually authenticated.
35 NTSTATUS
gensec_external_init(TALLOC_CTX
*ctx
);
37 static NTSTATUS
gensec_external_start(struct gensec_security
*gensec_security
)
39 if (gensec_security
->want_features
& GENSEC_FEATURE_SIGN
)
40 return NT_STATUS_INVALID_PARAMETER
;
41 if (gensec_security
->want_features
& GENSEC_FEATURE_SEAL
)
42 return NT_STATUS_INVALID_PARAMETER
;
47 struct gensec_external_update_state
{
51 static struct tevent_req
*gensec_external_update_send(TALLOC_CTX
*mem_ctx
,
52 struct tevent_context
*ev
,
53 struct gensec_security
*gensec_security
,
56 struct tevent_req
*req
;
57 struct gensec_external_update_state
*state
= NULL
;
59 req
= tevent_req_create(mem_ctx
, &state
,
60 struct gensec_external_update_state
);
65 state
->out
= data_blob_talloc(state
, "", 0);
66 if (tevent_req_nomem(state
->out
.data
, req
)) {
67 return tevent_req_post(req
, ev
);
71 return tevent_req_post(req
, ev
);
74 static NTSTATUS
gensec_external_update_recv(struct tevent_req
*req
,
75 TALLOC_CTX
*out_mem_ctx
,
78 struct gensec_external_update_state
*state
=
80 struct gensec_external_update_state
);
83 *out
= data_blob_null
;
85 if (tevent_req_is_nterror(req
, &status
)) {
86 tevent_req_received(req
);
91 tevent_req_received(req
);
95 /* We have no features */
96 static bool gensec_external_have_feature(struct gensec_security
*gensec_security
,
102 static const struct gensec_security_ops gensec_external_ops
= {
103 .name
= "sasl-EXTERNAL",
104 .sasl_name
= "EXTERNAL",
105 .client_start
= gensec_external_start
,
106 .update_send
= gensec_external_update_send
,
107 .update_recv
= gensec_external_update_recv
,
108 .have_feature
= gensec_external_have_feature
,
110 .priority
= GENSEC_EXTERNAL
114 NTSTATUS
gensec_external_init(TALLOC_CTX
*ctx
)
118 ret
= gensec_register(ctx
, &gensec_external_ops
);
119 if (!NT_STATUS_IS_OK(ret
)) {
120 DEBUG(0,("Failed to register '%s' gensec backend!\n",
121 gensec_external_ops
.name
));