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
67 struct GNUNET_CRYPTO_EcdsaPublicKey identity;
72 struct GNUNET_CRYPTO_EcdsaPublicKey audience;
75 * The ticket random (NBO)
81 * Handle for an operation with the identity provider service.
83 struct GNUNET_IDENTITY_PROVIDER_Operation;
86 * Flags that can be set for an attribute.
88 enum GNUNET_IDENTITY_PROVIDER_AttributeType
94 GNUNET_IDENTITY_PROVIDER_AT_NULL = 0,
99 GNUNET_IDENTITY_PROVIDER_AT_STRING = 1,
108 struct GNUNET_IDENTITY_PROVIDER_Attribute
114 uint32_t attribute_type;
117 * Number of bytes in @e data.
122 * The name of the attribute. Note "name" must never be individually
128 * Binary value stored as attribute value. Note: "data" must never
129 * be individually 'malloc'ed, but instead always points into some
130 * existing data area.
136 struct GNUNET_IDENTITY_PROVIDER_AttributeList
141 struct GNUNET_IDENTITY_PROVIDER_AttributeListEntry *list_head;
146 struct GNUNET_IDENTITY_PROVIDER_AttributeListEntry *list_tail;
149 struct GNUNET_IDENTITY_PROVIDER_AttributeListEntry
154 struct GNUNET_IDENTITY_PROVIDER_AttributeListEntry *prev;
159 struct GNUNET_IDENTITY_PROVIDER_AttributeListEntry *next;
164 struct GNUNET_IDENTITY_PROVIDER_Attribute *attribute;
168 * Connect to the identity provider service.
170 * @param cfg Configuration to contact the identity provider service.
171 * @return handle to communicate with identity provider service
173 struct GNUNET_IDENTITY_PROVIDER_Handle *
174 GNUNET_IDENTITY_PROVIDER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
177 * Continuation called to notify client about result of the
181 * @param success #GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate)
182 * #GNUNET_NO if content was already there or not found
183 * #GNUNET_YES (or other positive value) on success
184 * @param emsg NULL on success, otherwise an error message
187 (*GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus) (void *cls,
193 * Store an attribute. If the attribute is already present,
194 * it is replaced with the new attribute.
196 * @param h handle to the identity provider
197 * @param pkey private key of the identity
198 * @param attr the attribute
199 * @param cont continuation to call when done
200 * @param cont_cls closure for @a cont
201 * @return handle to abort the request
203 struct GNUNET_IDENTITY_PROVIDER_Operation *
204 GNUNET_IDENTITY_PROVIDER_attribute_store (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
205 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
206 const struct GNUNET_IDENTITY_PROVIDER_Attribute *attr,
207 GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus cont,
212 * Create a new attribute.
214 * @param name the attribute name
215 * @param type the attribute type
216 * @param data the attribute value
217 * @param data_size the attribute value size
218 * @return the new attribute
220 struct GNUNET_IDENTITY_PROVIDER_Attribute *
221 GNUNET_IDENTITY_PROVIDER_attribute_new (const char* attr_name,
227 * Process an attribute that was stored in the idp.
230 * @param attr the attribute
233 (*GNUNET_IDENTITY_PROVIDER_AttributeResult) (void *cls,
234 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
235 const struct GNUNET_IDENTITY_PROVIDER_Attribute *attr);
240 * List all attributes for a local identity.
241 * This MUST lock the `struct GNUNET_IDENTITY_PROVIDER_Handle`
242 * for any other calls than #GNUNET_IDENTITY_PROVIDER_get_attributes_next() and
243 * #GNUNET_IDENTITY_PROVIDER_get_attributes_stop. @a proc will be called once
244 * immediately, and then again after
245 * #GNUNET_IDENTITY_PROVIDER_get_attributes_next() is invoked.
247 * On error (disconnect), @a error_cb will be invoked.
248 * On normal completion, @a finish_cb proc will be
251 * @param h handle to the idp
252 * @param identity identity to access
253 * @param error_cb function to call on error (i.e. disconnect),
254 * the handle is afterwards invalid
255 * @param error_cb_cls closure for @a error_cb
256 * @param proc function to call on each attribute; it
257 * will be called repeatedly with a value (if available)
258 * @param proc_cls closure for @a proc
259 * @param finish_cb function to call on completion
260 * the handle is afterwards invalid
261 * @param finish_cb_cls closure for @a finish_cb
262 * @return an iterator handle to use for iteration
264 struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *
265 GNUNET_IDENTITY_PROVIDER_get_attributes_start (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
266 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
267 GNUNET_SCHEDULER_TaskCallback error_cb,
269 GNUNET_IDENTITY_PROVIDER_AttributeResult proc,
271 GNUNET_SCHEDULER_TaskCallback finish_cb,
272 void *finish_cb_cls);
276 * Calls the record processor specified in #GNUNET_IDENTITY_PROVIDER_get_attributes_start
277 * for the next record.
279 * @param it the iterator
282 GNUNET_IDENTITY_PROVIDER_get_attributes_next (struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it);
286 * Stops iteration and releases the idp handle for further calls. Must
287 * be called on any iteration that has not yet completed prior to calling
288 * #GNUNET_IDENTITY_PROVIDER_disconnect.
290 * @param it the iterator
293 GNUNET_IDENTITY_PROVIDER_get_attributes_stop (struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it);
297 * Method called when a token has been issued.
298 * On success returns a ticket that can be given to the audience to retrive the
302 * @param ticket the ticket
305 (*GNUNET_IDENTITY_PROVIDER_TicketCallback)(void *cls,
306 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket);
309 * Issues a ticket to another identity. The identity may use
310 * @GNUNET_IDENTITY_PROVIDER_authorization_ticket_consume to consume the ticket
311 * and retrieve the attributes specified in the AttributeList.
313 * @param id the identity provider to use
314 * @param iss the issuing identity
315 * @param rp the subject of the ticket (the relying party)
316 * @param attr the attributes that the relying party is given access to
317 * @param cb the callback
318 * @param cb_cls the callback closure
319 * @return handle to abort the operation
321 struct GNUNET_IDENTITY_PROVIDER_Operation *
322 GNUNET_IDENTITY_PROVIDER_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handle *id,
323 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
324 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
325 const struct GNUNET_IDENTITY_PROVIDER_AttributeList *attrs,
326 GNUNET_IDENTITY_PROVIDER_TicketCallback cb,
330 * Revoked an issued ticket. The relying party will be unable to retrieve
331 * updated attributes.
333 * @param id the identity provider to use
334 * @param identity the issuing identity
335 * @param ticket the ticket to revoke
336 * @param cb the callback
337 * @param cb_cls the callback closure
338 * @return handle to abort the operation
340 struct GNUNET_IDENTITY_PROVIDER_Operation *
341 GNUNET_IDENTITY_PROVIDER_ticket_revoke (struct GNUNET_IDENTITY_PROVIDER_Handle *id,
342 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
343 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
344 GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus cb,
350 * Consumes an issued ticket. The ticket is persisted
351 * and used to retrieve identity information from the issuer
353 * @param id the identity provider to use
354 * @param identity the identity that is the subject of the issued ticket (the audience)
355 * @param ticket the issued ticket to consume
356 * @param cb the callback to call
357 * @param cb_cls the callback closure
358 * @return handle to abort the operation
360 struct GNUNET_IDENTITY_PROVIDER_Operation *
361 GNUNET_IDENTITY_PROVIDER_ticket_consume (struct GNUNET_IDENTITY_PROVIDER_Handle *id,
362 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
363 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
364 GNUNET_IDENTITY_PROVIDER_AttributeResult cb,
368 * Lists all tickets that have been issued to remote
369 * identites (relying parties)
371 * @param h the identity provider to use
372 * @param identity the issuing identity
373 * @param error_cb function to call on error (i.e. disconnect),
374 * the handle is afterwards invalid
375 * @param error_cb_cls closure for @a error_cb
376 * @param proc function to call on each ticket; it
377 * will be called repeatedly with a value (if available)
378 * @param proc_cls closure for @a proc
379 * @param finish_cb function to call on completion
380 * the handle is afterwards invalid
381 * @param finish_cb_cls closure for @a finish_cb
382 * @return an iterator handle to use for iteration
384 struct GNUNET_IDENTITY_PROVIDER_TicketIterator *
385 GNUNET_IDENTITY_PROVIDER_ticket_iteration_start (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
386 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
387 GNUNET_SCHEDULER_TaskCallback error_cb,
389 GNUNET_IDENTITY_PROVIDER_TicketCallback proc,
391 GNUNET_SCHEDULER_TaskCallback finish_cb,
392 void *finish_cb_cls);
395 * Lists all tickets that have been issued to remote
396 * identites (relying parties)
398 * @param id the identity provider to use
399 * @param identity the issuing identity
400 * @param error_cb function to call on error (i.e. disconnect),
401 * the handle is afterwards invalid
402 * @param error_cb_cls closure for @a error_cb
403 * @param proc function to call on each ticket; it
404 * will be called repeatedly with a value (if available)
405 * @param proc_cls closure for @a proc
406 * @param finish_cb function to call on completion
407 * the handle is afterwards invalid
408 * @param finish_cb_cls closure for @a finish_cb
409 * @return an iterator handle to use for iteration
411 struct GNUNET_IDENTITY_PROVIDER_TicketIterator *
412 GNUNET_IDENTITY_PROVIDER_ticket_iteration_start_rp (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
413 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
414 GNUNET_SCHEDULER_TaskCallback error_cb,
416 GNUNET_IDENTITY_PROVIDER_TicketCallback proc,
418 GNUNET_SCHEDULER_TaskCallback finish_cb,
419 void *finish_cb_cls);
422 * Calls the record processor specified in #GNUNET_IDENTITY_PROVIDER_ticket_iteration_start
423 * for the next record.
425 * @param it the iterator
428 GNUNET_IDENTITY_PROVIDER_ticket_iteration_next (struct GNUNET_IDENTITY_PROVIDER_TicketIterator *it);
431 * Stops iteration and releases the idp handle for further calls. Must
432 * be called on any iteration that has not yet completed prior to calling
433 * #GNUNET_IDENTITY_PROVIDER_disconnect.
435 * @param it the iterator
438 GNUNET_IDENTITY_PROVIDER_ticket_iteration_stop (struct GNUNET_IDENTITY_PROVIDER_TicketIterator *it);
441 * Disconnect from identity provider service.
443 * @param h identity provider service to disconnect
446 GNUNET_IDENTITY_PROVIDER_disconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h);
450 * Cancel an identity provider operation. Note that the operation MAY still
451 * be executed; this merely cancels the continuation; if the request
452 * was already transmitted, the service may still choose to complete
455 * @param op operation to cancel
458 GNUNET_IDENTITY_PROVIDER_cancel (struct GNUNET_IDENTITY_PROVIDER_Operation *op);
460 #if 0 /* keep Emacsens' auto-indent happy */
468 /* ifndef GNUNET_IDENTITY_PROVIDER_SERVICE_H */
471 /** @} */ /* end of group identity */
473 /* end of gnunet_identity_provider_service.h */