summaryrefslogtreecommitdiffstats
path: root/src/krb5_plugin/idp/idp.h
blob: c9645804c9dd956d4fccfe1c8ec25f4975b622fb (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
/*
    Authors:
        Pavel Březina <pbrezina@redhat.com>

    Copyright (C) 2021 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 _IDP_H_
#define _IDP_H_

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

#ifndef discard_const
#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
#endif

#define SSSD_IDP_PLUGIN "idp"
#define SSSD_IDP_CONFIG "idp"
#define SSSD_IDP_OAUTH2_PADATA 152 // PA-REDHAT-IDP-OAUTH2
#define SSSD_IDP_OAUTH2_QUESTION "idp-oauth2"
#define SSSD_IDP_OAUTH2_PREFIX "oauth2 "

struct sss_idp_config {
    char *type;
    char **indicators;
};

void
sss_idp_config_free(struct sss_idp_config *idpcfg);

krb5_error_code
sss_idp_config_init(const char *config,
                    struct sss_idp_config **_idpcfg);

struct sss_idp_oauth2 {
    char *verification_uri;
    char *verification_uri_complete;
    char *user_code;
};

void
sss_idp_oauth2_free(struct sss_idp_oauth2 *data);

krb5_pa_data *
sss_idp_oauth2_encode_padata(struct sss_idp_oauth2 *data);

struct sss_idp_oauth2 *
sss_idp_oauth2_decode_padata(krb5_pa_data *padata);

char *
sss_idp_oauth2_encode_challenge(struct sss_idp_oauth2 *data);

struct sss_idp_oauth2 *
sss_idp_oauth2_decode_challenge(const char *str);

#endif /* _IDP_H_ */