summaryrefslogtreecommitdiffstats
path: root/src/krb5_plugin/common/radius_kdcpreauth.h
blob: 7e032b36fcc5f3b0903d603adb261df52e1e2eff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*
    Authors:
        Pavel Březina <pbrezina@redhat.com>

    Copyright (C) 2023 Red Hat

    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 3 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, see <http://www.gnu.org/licenses/>.
*/

#ifndef _RADIUS_KDCPREAUTH_H_
#define _RADIUS_KDCPREAUTH_H_

#include <stdlib.h>
#include <krb5/preauth_plugin.h>

struct sss_radiuskdc_state {
    const char *plugin_name;
    const char *server;
    const char *secret;
    size_t retries;
    int timeout;
};

struct sss_radiuskdc_config {
    char *username;
    char *server;
    char *secret;
    size_t retries;
    int timeout;
};

struct sss_radiuskdc_client {
    krad_client *client;
    krad_attrset *attrs;
};

struct sss_radiuskdc_challenge {
    struct sss_radiuskdc_client *client;

    krb5_context kctx;
    krb5_kdcpreauth_callbacks cb;
    krb5_kdcpreauth_rock rock;
    krb5_kdcpreauth_edata_respond_fn respond;
    void *arg;
};

struct sss_radiuskdc_verify {
    struct sss_radiuskdc_client *client;
    char **indicators;

    krb5_context kctx;
    krb5_kdcpreauth_rock rock;
    krb5_kdcpreauth_callbacks cb;
    krb5_enc_tkt_part *enc_tkt_reply;
    krb5_kdcpreauth_verify_respond_fn respond;
    void *arg;
};

krb5_error_code
sss_radiuskdc_init(const char *plugin_name,
                   krb5_context kctx,
                   krb5_kdcpreauth_moddata *_moddata,
                   const char **_realmnames);

void
sss_radiuskdc_fini(krb5_context kctx,
                   krb5_kdcpreauth_moddata moddata);

int
sss_radiuskdc_flags(krb5_context kctx,
                    krb5_preauthtype pa_type);

krb5_error_code
sss_radiuskdc_return_padata(krb5_context kctx,
                            krb5_pa_data *padata,
                            krb5_data *req_pkt,
                            krb5_kdc_req *request,
                            krb5_kdc_rep *reply,
                            krb5_keyblock *encrypting_key,
                            krb5_pa_data **send_pa_out,
                            krb5_kdcpreauth_callbacks cb,
                            krb5_kdcpreauth_rock rock,
                            krb5_kdcpreauth_moddata moddata,
                            krb5_kdcpreauth_modreq modreq);

krb5_error_code
sss_radiuskdc_enabled(const char *config_name,
                      krb5_context kctx,
                      krb5_kdcpreauth_callbacks cb,
                      krb5_kdcpreauth_rock rock,
                      char **_config);

void
sss_radiuskdc_config_free(struct sss_radiuskdc_config *config);

krb5_error_code
sss_radiuskdc_config_init(struct sss_radiuskdc_state *state,
                          krb5_context kctx,
                          krb5_const_principal princ,
                          const char *configstr,
                          struct sss_radiuskdc_config **_config);

krb5_error_code
sss_radiuskdc_set_cookie(krb5_context context,
                         krb5_kdcpreauth_callbacks cb,
                         krb5_kdcpreauth_rock rock,
                         krb5_preauthtype pa_type,
                         const krb5_data *state);

krb5_error_code
sss_radiuskdc_get_cookie(krb5_context context,
                         krb5_kdcpreauth_callbacks cb,
                         krb5_kdcpreauth_rock rock,
                         krb5_preauthtype pa_type,
                         krb5_data *_state);

krb5_error_code
sss_radiuskdc_get_complete_attr(const krad_packet *rres,
                                const char *attr_name,
                                krb5_data *_data);

krb5_error_code
sss_radiuskdc_put_complete_attr(krad_attrset *attrset,
                                krad_attr attr,
                                const krb5_data *datap);

char *
sss_radiuskdc_get_attr_as_string(const krad_packet *packet, const char *attr);


krb5_error_code
sss_radiuskdc_set_attr_as_string(krad_attrset *attrset,
                                 const char *attr,
                                 const char *value);

void
sss_radiuskdc_client_free(struct sss_radiuskdc_client *client);

struct sss_radiuskdc_client *
sss_radiuskdc_client_init(krb5_context kctx,
                          verto_ctx *vctx,
                          struct sss_radiuskdc_config *config);

void
sss_radiuskdc_challenge_free(struct sss_radiuskdc_challenge *state);

struct sss_radiuskdc_challenge *
sss_radiuskdc_challenge_init(krb5_context kctx,
                             krb5_kdcpreauth_callbacks cb,
                             krb5_kdcpreauth_rock rock,
                             krb5_kdcpreauth_edata_respond_fn respond,
                             void *arg,
                             struct sss_radiuskdc_config *config);

void
sss_radiuskdc_verify_free(struct sss_radiuskdc_verify *state);

struct sss_radiuskdc_verify *
sss_radiuskdc_verify_init(krb5_context kctx,
                          krb5_kdcpreauth_rock rock,
                          krb5_kdcpreauth_callbacks cb,
                          krb5_enc_tkt_part *enc_tkt_reply,
                          krb5_kdcpreauth_verify_respond_fn respond,
                          void *arg,
                          char **indicators,
                          struct sss_radiuskdc_config *config);

void
sss_radiuskdc_verify_done(krb5_error_code rret,
                          const krad_packet *rreq,
                          const krad_packet *rres,
                          void *data);

#endif /* _RADIUS_KDCPREAUTH_H_ */