diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-03-12 09:36:17 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-03-12 09:36:17 +0100 |
commit | 919bb8c92fa1b7cda53401ff2286b980ca0b12d8 (patch) | |
tree | b0ab4ebf063c0ccb2a4b8095463d1e7a6884bf2e /src/reclaim/oidc_helper.h | |
parent | 76c6ccfdfe09891db424ead5209f041f0e71dc63 (diff) | |
download | gnunet-919bb8c92fa1b7cda53401ff2286b980ca0b12d8.tar.gz gnunet-919bb8c92fa1b7cda53401ff2286b980ca0b12d8.zip |
move reclaim and gns back into subdirs
Diffstat (limited to 'src/reclaim/oidc_helper.h')
-rw-r--r-- | src/reclaim/oidc_helper.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/src/reclaim/oidc_helper.h b/src/reclaim/oidc_helper.h new file mode 100644 index 000000000..d718b7a78 --- /dev/null +++ b/src/reclaim/oidc_helper.h | |||
@@ -0,0 +1,111 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2010-2015 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file reclaim/oidc_helper.h | ||
23 | * @brief helper library for OIDC related functions | ||
24 | * @author Martin Schanzenbach | ||
25 | */ | ||
26 | |||
27 | #ifndef JWT_H | ||
28 | #define JWT_H | ||
29 | |||
30 | #define JWT_ALG "alg" | ||
31 | |||
32 | /* Use 512bit HMAC */ | ||
33 | #define JWT_ALG_VALUE "HS512" | ||
34 | |||
35 | #define JWT_TYP "typ" | ||
36 | |||
37 | #define JWT_TYP_VALUE "jwt" | ||
38 | |||
39 | #define SERVER_ADDRESS "https://api.reclaim" | ||
40 | |||
41 | /** | ||
42 | * Create a JWT from attributes | ||
43 | * | ||
44 | * @param aud_key the public of the audience | ||
45 | * @param sub_key the public key of the subject | ||
46 | * @param attrs the attribute list | ||
47 | * @param expiration_time the validity of the token | ||
48 | * @param secret_key the key used to sign the JWT | ||
49 | * @return a new base64-encoded JWT string. | ||
50 | */ | ||
51 | char* | ||
52 | OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, | ||
53 | const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key, | ||
54 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, | ||
55 | const struct GNUNET_TIME_Relative *expiration_time, | ||
56 | const char *nonce, | ||
57 | const char *secret_key); | ||
58 | |||
59 | /** | ||
60 | * Builds an OIDC authorization code including | ||
61 | * a reclaim ticket and nonce | ||
62 | * | ||
63 | * @param issuer the issuer of the ticket, used to sign the ticket and nonce | ||
64 | * @param ticket the ticket to include in the code | ||
65 | * @param nonce the nonce to include in the code | ||
66 | * @return a new authorization code (caller must free) | ||
67 | */ | ||
68 | char* | ||
69 | OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, | ||
70 | const struct GNUNET_RECLAIM_Ticket *ticket, | ||
71 | const char* nonce); | ||
72 | |||
73 | /** | ||
74 | * Parse reclaim ticket and nonce from | ||
75 | * authorization code. | ||
76 | * This also verifies the signature in the code. | ||
77 | * | ||
78 | * @param audience the expected audience of the code | ||
79 | * @param code the string representation of the code | ||
80 | * @param ticket where to store the ticket | ||
81 | * @param nonce where to store the nonce | ||
82 | * @return GNUNET_OK if successful, else GNUNET_SYSERR | ||
83 | */ | ||
84 | int | ||
85 | OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, | ||
86 | const char* code, | ||
87 | struct GNUNET_RECLAIM_Ticket **ticket, | ||
88 | char **nonce); | ||
89 | |||
90 | /** | ||
91 | * Build a token response for a token request | ||
92 | * TODO: Maybe we should add the scope here? | ||
93 | * | ||
94 | * @param access_token the access token to include | ||
95 | * @param id_token the id_token to include | ||
96 | * @param expiration_time the expiration time of the token(s) | ||
97 | * @param token_response where to store the response | ||
98 | */ | ||
99 | void | ||
100 | OIDC_build_token_response (const char *access_token, | ||
101 | const char *id_token, | ||
102 | const struct GNUNET_TIME_Relative *expiration_time, | ||
103 | char **token_response); | ||
104 | /** | ||
105 | * Generate a new access token | ||
106 | */ | ||
107 | char* | ||
108 | OIDC_access_token_new (); | ||
109 | |||
110 | |||
111 | #endif | ||