aboutsummaryrefslogtreecommitdiff
path: root/src/rest-plugins/oidc_helper.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/rest-plugins/oidc_helper.h')
-rw-r--r--src/rest-plugins/oidc_helper.h109
1 files changed, 109 insertions, 0 deletions
diff --git a/src/rest-plugins/oidc_helper.h b/src/rest-plugins/oidc_helper.h
new file mode 100644
index 000000000..7a0f45bf9
--- /dev/null
+++ b/src/rest-plugins/oidc_helper.h
@@ -0,0 +1,109 @@
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
19/**
20 * @file reclaim/oidc_helper.h
21 * @brief helper library for OIDC related functions
22 * @author Martin Schanzenbach
23 */
24
25#ifndef JWT_H
26#define JWT_H
27
28#define JWT_ALG "alg"
29
30/* Use 512bit HMAC */
31#define JWT_ALG_VALUE "HS512"
32
33#define JWT_TYP "typ"
34
35#define JWT_TYP_VALUE "jwt"
36
37#define SERVER_ADDRESS "https://reclaim.id"
38
39/**
40 * Create a JWT from attributes
41 *
42 * @param aud_key the public of the audience
43 * @param sub_key the public key of the subject
44 * @param attrs the attribute list
45 * @param expiration_time the validity of the token
46 * @param secret_key the key used to sign the JWT
47 * @return a new base64-encoded JWT string.
48 */
49char*
50OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
51 const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
52 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
53 const struct GNUNET_TIME_Relative *expiration_time,
54 const char *nonce,
55 const char *secret_key);
56
57/**
58 * Builds an OIDC authorization code including
59 * a reclaim ticket and nonce
60 *
61 * @param issuer the issuer of the ticket, used to sign the ticket and nonce
62 * @param ticket the ticket to include in the code
63 * @param nonce the nonce to include in the code
64 * @return a new authorization code (caller must free)
65 */
66char*
67OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
68 const struct GNUNET_RECLAIM_Ticket *ticket,
69 const char* nonce);
70
71/**
72 * Parse reclaim ticket and nonce from
73 * authorization code.
74 * This also verifies the signature in the code.
75 *
76 * @param audience the expected audience of the code
77 * @param code the string representation of the code
78 * @param ticket where to store the ticket
79 * @param nonce where to store the nonce
80 * @return GNUNET_OK if successful, else GNUNET_SYSERR
81 */
82int
83OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
84 const char* code,
85 struct GNUNET_RECLAIM_Ticket **ticket,
86 char **nonce);
87
88/**
89 * Build a token response for a token request
90 * TODO: Maybe we should add the scope here?
91 *
92 * @param access_token the access token to include
93 * @param id_token the id_token to include
94 * @param expiration_time the expiration time of the token(s)
95 * @param token_response where to store the response
96 */
97void
98OIDC_build_token_response (const char *access_token,
99 const char *id_token,
100 const struct GNUNET_TIME_Relative *expiration_time,
101 char **token_response);
102/**
103 * Generate a new access token
104 */
105char*
106OIDC_access_token_new ();
107
108
109#endif