2 This file is part of GNUnet.
3 Copyright (C) 2016 GNUnet e.V.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @author Martin Schanzenbach
25 * Identity provider service; implements identity provider for GNUnet
27 * @defgroup identity-provider Identity Provider service
30 #ifndef GNUNET_IDENTITY_PROVIDER_SERVICE_H
31 #define GNUNET_IDENTITY_PROVIDER_SERVICE_H
36 #if 0 /* keep Emacsens' auto-indent happy */
41 #include "gnunet_util_lib.h"
45 * Version number of GNUnet Identity Provider API.
47 #define GNUNET_IDENTITY_PROVIDER_VERSION 0x00000000
50 * Handle to access the identity service.
52 struct GNUNET_IDENTITY_PROVIDER_Handle;
57 struct GNUNET_IDENTITY_PROVIDER_Token;
62 struct GNUNET_IDENTITY_PROVIDER_Ticket;
65 * Handle for an operation with the identity provider service.
67 struct GNUNET_IDENTITY_PROVIDER_Operation;
70 * Method called when a token has been exchanged for a ticket.
71 * On success returns a token
74 * @param token the token
77 (*GNUNET_IDENTITY_PROVIDER_ExchangeCallback)(void *cls,
78 const struct GNUNET_IDENTITY_PROVIDER_Token *token,
79 uint64_t ticket_nonce);
82 * Method called when a token has been issued.
83 * On success returns a ticket that can be given to the audience to retrive the
87 * @param grant the label in GNS pointing to the token
88 * @param ticket the ticket
89 * @param token the issued token
90 * @param name name assigned by the user for this ego,
91 * NULL if the user just deleted the ego and it
92 * must thus no longer be used
95 (*GNUNET_IDENTITY_PROVIDER_IssueCallback)(void *cls,
97 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
98 const struct GNUNET_IDENTITY_PROVIDER_Token *token);
102 * Connect to the identity provider service.
104 * @param cfg Configuration to contact the identity provider service.
105 * @return handle to communicate with identity provider service
107 struct GNUNET_IDENTITY_PROVIDER_Handle *
108 GNUNET_IDENTITY_PROVIDER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
112 * Issue a token for a specific audience.
114 * @param id identity provider service to use
115 * @param iss issuer (identity)
116 * @param aud audience (identity)
117 * @param scope the identity attributes requested, comman separated
118 * @param expiration the token expiration
119 * @param nonce the nonce that will be included in token and ticket
120 * @param cb callback to call with result
121 * @param cb_cls closure
122 * @return handle to abort the operation
124 struct GNUNET_IDENTITY_PROVIDER_Operation *
125 GNUNET_IDENTITY_PROVIDER_issue_token (struct GNUNET_IDENTITY_PROVIDER_Handle *id,
126 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss_key,
127 const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key,
129 struct GNUNET_TIME_Absolute expiration,
131 GNUNET_IDENTITY_PROVIDER_IssueCallback cb,
136 * Exchange a ticket for a token. Intended to be used by audience that
139 * @param id identity provider service to use
140 * @param ticket the ticket to exchange
141 * @param aud_privkey the audience of the ticket
142 * @param cont function to call once the operation finished
143 * @param cont_cls closure for @a cont
144 * @return handle to abort the operation
146 struct GNUNET_IDENTITY_PROVIDER_Operation *
147 GNUNET_IDENTITY_PROVIDER_exchange_ticket (struct GNUNET_IDENTITY_PROVIDER_Handle *id,
148 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
149 const struct GNUNET_CRYPTO_EcdsaPrivateKey *aud_privkey,
150 GNUNET_IDENTITY_PROVIDER_ExchangeCallback cont,
155 * Disconnect from identity provider service.
157 * @param h identity provider service to disconnect
160 GNUNET_IDENTITY_PROVIDER_disconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h);
164 * Cancel an identity provider operation. Note that the operation MAY still
165 * be executed; this merely cancels the continuation; if the request
166 * was already transmitted, the service may still choose to complete
169 * @param op operation to cancel
172 GNUNET_IDENTITY_PROVIDER_cancel (struct GNUNET_IDENTITY_PROVIDER_Operation *op);
182 * @param token the token
185 GNUNET_IDENTITY_PROVIDER_token_destroy(struct GNUNET_IDENTITY_PROVIDER_Token *token);
188 * Returns string representation of token. A JSON-Web-Token.
190 * @param token the token
191 * @return The JWT (must be freed)
194 GNUNET_IDENTITY_PROVIDER_token_to_string (const struct GNUNET_IDENTITY_PROVIDER_Token *token);
197 * Returns string representation of ticket. Base64-Encoded
199 * @param ticket the ticket
200 * @return the Base64-Encoded ticket
203 GNUNET_IDENTITY_PROVIDER_ticket_to_string (const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket);
206 * Created a ticket from a string (Base64 encoded ticket)
208 * @param input Base64 encoded ticket
209 * @param ticket pointer where the ticket is stored
213 GNUNET_IDENTITY_PROVIDER_string_to_ticket (const char* input,
214 struct GNUNET_IDENTITY_PROVIDER_Ticket **ticket);
219 * @param ticket the ticket to destroy
222 GNUNET_IDENTITY_PROVIDER_ticket_destroy(struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket);
224 #if 0 /* keep Emacsens' auto-indent happy */
232 /* ifndef GNUNET_IDENTITY_PROVIDER_SERVICE_H */
235 /** @} */ /* end of group identity */
237 /* end of gnunet_identity_provider_service.h */