Liberator Auth API  7.1.13.29687-ca4d64a
rttpd.h
Go to the documentation of this file.
1 #ifndef __RTTPD_H__
2 #define __RTTPD_H__
3 
4 
5 #include <time.h>
6 #include <sys/types.h>
7 #ifndef WIN32
8 #include <netinet/in.h>
9 #endif
10 
11 
12 #define RTTPD_VERSION "7.1.13"
13 
14 #define RTTPD_MAJOR_VERSION 7
15 #define RTTPD_MINOR_VERSION 1
16 #define RTTPD_PATCH_VERSION 13
17 
18 
19 #ifdef WIN32
20 #ifndef AUTH_EXPORT
21 #define AUTH_EXPORT extern __declspec(dllimport)
22 #endif
23 #else
24 #define AUTH_EXPORT
25 #endif
26 
27 
28 
34 #define MAX_OBNAME 4096
35 
36 
38 #define MAX_USERNAME 255
39 
40 typedef struct _string_pair_type string_pair_t;
41 
42 typedef struct _authfuncs authfuncs_t;
43 
44 typedef struct _user user_t;
45 
46 typedef struct _session session_t;
47 
48 typedef struct _object object_t;
49 
50 typedef struct _nodeinfo nodeinfo_t;
51 
52 typedef struct _logininfo logininfo_t;
53 
54 typedef struct _mapinfo mapinfo_t;
55 
56 typedef struct _checkwriteinfo checkwriteinfo_t;
57 
58 
66 typedef void (*eventcallback_t)(void *data, short event, short code);
67 
68 
72 {
73  UNKNOWN_TYPE = 200,
74  USER_TYPE = 202,
76  PAGE_TYPE = 221,
77  RECORD_TYPE = 222,
78  NEWS_TYPE = 223,
79  STORY_TYPE = 224,
80  RECORD_TYPE2 = 225,
81  RECORD_TYPE3 = 226,
82  CHAT_TYPE = 227,
84  PERM_TYPE = 230,
85  INFO_TYPE = 201,
86  GENERIC_TYPE = 231,
87  JSON_TYPE = 232,
88 };
89 
90 typedef enum _object_type object_type_t;
91 
92 
112 char *auth_filename_expand(char *format, char *buf, size_t buflen);
113 
114 
120 {
121  AUTH_AGAIN = 2,
122  AUTH_DELAYED = 1,
123  AUTH_OK = 0,
124  AUTH_DENY = -1,
125  AUTH_FALSE = -2,
126  AUTH_INVALID_USER = -3,
127  AUTH_INVALID_PASS = -4,
128  AUTH_INVALID_ADDR = -5,
129  AUTH_ACCT_EXPIRED = -6,
130  AUTH_USER_LC_EXCEEDED = -7,
131  AUTH_SITE_LC_EXCEEDED = -8,
132  AUTH_ERROR = -9,
133  AUTH_USER1 = -99,
134  AUTH_USER2 = -98,
135  AUTH_USER3 = -97,
136  AUTH_USER4 = -96,
137  AUTH_USER5 = -95,
138 };
139 
140 
144 {
148 };
149 
150 typedef enum _auth_perm_operation auth_perm_operation_t;
151 
152 typedef struct _auth_map_type auth_map_t;
153 
154 struct _auth_map_type
155 {
156  char* key;
157  char* value;
158 };
159 
160 enum _http_method
161 {
162  M_HTTP_GET = 1,
163  M_HTTP_HEAD = 2,
164  M_HTTP_POST = 3,
165  M_HTTP_PUT = 4,
166  M_HTTP_DELETE = 5,
167 };
168 
169 typedef enum _http_method http_method_t;
170 
171 
177 {
178  int (*auth_new_user)(session_t *session, char *user, char *pass);
179 
193  int (*auth_free_user)(session_t *session);
194 
202  int (*auth_new_object)(object_t *obj, object_t *parent);
203 
214  int (*auth_free_object)(object_t *obj);
215 
225  int (*auth_check_read)(session_t *session, object_t *obj, char *requested_name);
226 
246  int (*auth_check_write)(session_t *session, object_t *obj, char *requested_name);
247 
268  int (*auth_map_object)(session_t *session, char *requested_name, char *name, char *mapped, int *len);
269 
289  int (*auth_request_object)(session_t *session, object_t *obj);
290 
302  int (*auth_discard_object)(session_t *session, object_t *obj);
303 
315  int (*auth_http_request)(char *user, char *pass, http_method_t method, char *path);
316 
331  int (*auth_check_update)(session_t *session, object_t *obj, char *data);
332 
348  int (*auth_check_permission_update)(session_t *session, object_t *obj, char *key, int auth_map_size, auth_map_t *keyvalues);
349  void (*auth_exit)();
350 
353  int (*auth_check_write_extended)(session_t *session, object_t *obj, char *requested_name, int field_count, string_pair_t * fields, char *contrib_id);
354 
378  void (*auth_global_permission_update)(object_t *obj, char *key, int auth_map_size, auth_map_t *keyvalues, auth_perm_operation_t operation);
379 
389 };
390 
391 
400 struct _user
401  {
402  char *username;
403  char *password;
404  int ref;
405  void *auth;
407  };
408 
409 struct _string_pair_type
410 {
411  char* name;
412  char* value;
413 };
414 
415 AUTH_EXPORT int auth_eject_sessions(user_t *user, int num);
416 
417 AUTH_EXPORT int auth_eject_sessions_by_app_id(user_t *user, int num, char *app_id);
418 
419 AUTH_EXPORT int auth_eject_sessions_by_machine_id(user_t *user, int num, char *machine_id);
420 
421 AUTH_EXPORT int auth_eject_all_sessions_by_app_id(const char *app_id);
422 
423 AUTH_EXPORT void auth_invalidate_sessions(user_t *user, int num, int flags);
424 
425 AUTH_EXPORT void auth_invalidate_sessions_by_name(char *name, int num, int flags);
426 
427 AUTH_EXPORT void auth_invalidate_all_sessions(int flags);
428 
429 AUTH_EXPORT void auth_invalidate_object(char *name, int flags);
430 
431 AUTH_EXPORT int signature_check(char *key_id, char *token);
432 
433 AUTH_EXPORT void auth_session_throttle(char *session_id, char *command);
434 
435 AUTH_EXPORT void auth_listener_throttle(char *session_id, char * object_name, char *command);
436 
437 AUTH_EXPORT int auth_get_user_session_count_by_name(char * object_name);
438 
439 AUTH_EXPORT int auth_eject_username_sessions(char *name, int num);
440 
441 AUTH_EXPORT int auth_eject_username_by_app_id(char *name, int num, char *app_id);
442 
443 AUTH_EXPORT int auth_eject_username_by_machine_id(char *name, int num, char *machine_id);
444 
445 AUTH_EXPORT int auth_create_object(char *name, object_type_t type);
446 
447 AUTH_EXPORT void auth_delete_object(char *name);
448 
449 AUTH_EXPORT int auth_verify_signature_username(char *expected_username, char *token);
450 
451 AUTH_EXPORT int auth_get_login_count(char *username);
452 
453 AUTH_EXPORT size_t auth_get_extra_data(char *token, char *buffer, size_t max_len);
454 
455 AUTH_EXPORT char *auth_get_token_parameter(const char *keymaster_token, const char *parameter_to_query);
456 
457 AUTH_EXPORT int auth_new_subscription(char *prefix, char *subject, void *user_context, void (*loaded)(void *, int, char *), void (*failed)(void *, int, char *), void (*status)(void *, int, char *, int));
458 
459 AUTH_EXPORT void auth_subscribe(int subscriptionId);
460 
461 AUTH_EXPORT void auth_unsubscribe(int subscriptionId);
462 
463 AUTH_EXPORT void auth_unsubscribe_free_data(int subscriptionId, void *free_context, void (*free_data_cb)(void *, void *));
464 
465 AUTH_EXPORT void auth_set_tobouser(const char *username, const char *tobouser);
466 
467 AUTH_EXPORT char *auth_get_tobouser(const char *username);
468 
469 AUTH_EXPORT void auth_reset_tobouser(const char *username);
470 
471 
473 #define SESSION_ID_LEN_MIN 6
474 
475 
477 #define SESSION_ID_LEN_DEFAULT 22
478 
479 
481 #define SESSION_ID_LEN_MAX 256
482 
483 
485 typedef struct _session_request_retry session_request_retry_t;
486 
487 
500 struct _session
501 {
502  char id[SESSION_ID_LEN_MAX+1];
503  int uid;
505  void *auth;
506  time_t s_connected;
507  time_t s_loggedin;
508  unsigned long s_updates;
509  struct sockaddr_storage addr;
510  char *addrname;
511  char type;
513  char *machine_id;
514  char *cookie;
516 };
517 
518 typedef struct _fieldset fieldset_t;
519 
520 
538 struct _object
539 {
540  char *name;
541  object_type_t type;
542  void *auth;
543 };
544 
545 enum
546 {
547  THREADS_AUTH_LOGIN = 600,
548  THREADS_AUTH_MAPPED = 601,
549  THREADS_AUTH_CHECKWRITE = 602
550 };
551 
552 
567 {
568  char session_id[SESSION_ID_LEN_MAX+1];
569  short msg;
570 };
571 
572 
579 struct _mapinfo
580 {
581  char session_id[SESSION_ID_LEN_MAX+1];
582  short msg;
583  char name[MAX_OBNAME+1];
584  char mapped[MAX_OBNAME+1];
585 };
586 
587 struct _checkwriteinfo
588 {
589  char session_id[SESSION_ID_LEN_MAX+1];
590  short msg;
591  char name[MAX_OBNAME+1]; /* The name of the object that is being contributed to */
592  char contrib_id[5];
593 };
594 
595 AUTH_EXPORT char *object_get_value(object_t *obj, int32_t fieldnum, char *buf, int len);
596 
597 AUTH_EXPORT char *object_get_value_byname(object_t *obj, char *fieldname, char *buf, int len);
598 
599 AUTH_EXPORT int infoob_add_field(const char *name, int flags);
600 
601 AUTH_EXPORT object_t *infoob_new_object(const char *name);
602 
603 AUTH_EXPORT void infoob_add_str(object_t *obj, int field, const char *value);
604 
605 AUTH_EXPORT void infoob_add_int(object_t *obj, int field, int value);
606 
607 AUTH_EXPORT void infoob_add_data(object_t *obj, const int *fields, const char **values, int count);
608 
609 AUTH_EXPORT void infoob_add_str_generic(object_t *obj, const char *fieldname, const char *value);
610 
611 AUTH_EXPORT void infoob_add_int_generic(object_t *obj, const char *fieldname, int value);
612 
613 AUTH_EXPORT void infoob_add_data_generic(object_t *obj, const char **fieldnames, const char **values, int count);
614 
615 
621 struct _nodeinfo
622  {
623  char *nodename;
624  unsigned short sessions;
625  unsigned short max_sessions;
626  };
627 
628 
629 #endif /* __RTTPD_H__ */
AUTH_EXPORT int auth_eject_username_by_app_id(char *name, int num, char *app_id)
Wrapper for auth_eject_username_by_app_id that takes the user name instead of a _user pointer...
Definition: auth.c:2087
char * authorization
Definition: rttpd.h:515
Describes the callback functions that should be implemented by an auth module.
Definition: rttpd.h:176
AUTH_EXPORT int auth_verify_signature_username(char *expected_username, char *token)
Verify that the supplied token is for the expected username.
Definition: auth.c:6187
Definition: rttpd.h:87
Definition: rttpd.h:74
The user object.
Definition: rttpd.h:400
Definition: rttpd.h:75
Definition: rttpd.h:78
char * addrname
Definition: rttpd.h:510
Definition: rttpd.h:77
char * tobo_username
Definition: rttpd.h:406
AUTH_EXPORT void auth_invalidate_sessions(user_t *user, int num, int flags)
Invalidate all sessions for a user.
Definition: auth.c:2340
struct _session_request_retry session_request_retry_t
Structure used to hold request retry information when things are overloaded.
Definition: rttpd.h:485
AUTH_EXPORT object_t * infoob_new_object(const char *name)
Creates a new system object.
Definition: infoob.c:171
Definition: rttpd.h:85
#define MAX_OBNAME
Definition: rttpd.h:34
void(* eventcallback_t)(void *data, short event, short code)
Definition of the callback function for delayed events.
Definition: rttpd.h:66
_auth_perm_operation
Operations for the __authfuncs::auth_global_permission_update() function.
Definition: rttpd.h:143
Definition: rttpd.h:83
int uid
Definition: rttpd.h:503
_object_type
Definition of RTTP object types.
Definition: rttpd.h:71
AUTH_EXPORT void auth_listener_throttle(char *session_id, char *object_name, char *command)
Throttle an individual subscription on a user&#39;s session.
Definition: auth.c:2513
AUTH_EXPORT int auth_eject_username_sessions(char *name, int num)
Wrapper for auth_eject_sessions that takes the user name instead of a _user pointer.
Definition: auth.c:1987
short msg
Definition: rttpd.h:569
Definition: rttpd.h:147
AUTH_EXPORT void infoob_add_str(object_t *obj, int field, const char *value)
Adds a value to a system object.
Definition: infoob.c:251
AUTH_EXPORT void auth_subscribe(int subscriptionId)
Subscribes to subject.
Definition: auth.c:6346
time_t s_loggedin
Definition: rttpd.h:507
AUTH_EXPORT void auth_unsubscribe_free_data(int subscriptionId, void *free_context, void(*free_data_cb)(void *, void *))
Unsubscribes to subject and frees the user context on the thread handling auth updates.
Definition: auth.c:6414
AUTH_EXPORT char * auth_get_tobouser(const char *username)
Get the TOBO user setting.
Definition: auth.c:5907
char * cookie
Definition: rttpd.h:514
AUTH_EXPORT int signature_check(char *key_id, char *token)
Provides a mechanism for validating a KeyMaster-generated encrypted single-use token.
Definition: auth.c:1447
AUTH_EXPORT int auth_eject_all_sessions_by_app_id(const char *app_id)
Eject all logged in sessions that are using the specified application id.
Definition: auth.c:2240
AUTH_EXPORT char * object_get_value(object_t *obj, int32_t fieldnum, char *buf, int len)
The function returns the value of a specified field in an object.
Definition: object.c:3904
Definition: rttpd.h:146
AUTH_EXPORT void auth_reset_tobouser(const char *username)
Remove the tobouser for the user specified by the session.
Definition: auth.c:5933
AUTH_EXPORT void auth_invalidate_all_sessions(int flags)
Invalidate all sessions for all users in the system.
Definition: auth.c:2436
void * auth
Definition: rttpd.h:405
char * nodename
Definition: rttpd.h:623
char * password
Definition: rttpd.h:403
AUTH_EXPORT void infoob_add_data(object_t *obj, const int *fields, const char **values, int count)
Adds an array of values to a system object.
Definition: infoob.c:298
AUTH_EXPORT void infoob_add_int_generic(object_t *obj, const char *fieldname, int value)
Adds a numerical value to a system object.
Definition: infoob.c:347
AUTH_EXPORT int auth_new_subscription(char *prefix, char *subject, void *user_context, void(*loaded)(void *, int, char *), void(*failed)(void *, int, char *), void(*status)(void *, int, char *, int))
Creates a subscription for use with auth_subscribe and auth_unsubscribe.
Definition: auth.c:6325
AUTH_EXPORT void auth_invalidate_sessions_by_name(char *name, int num, int flags)
Invalidate all sessions for a username.
Definition: auth.c:2377
AUTH_EXPORT void infoob_add_data_generic(object_t *obj, const char **fieldnames, const char **values, int count)
Adds an array of values to a system object.
Definition: infoob.c:370
AUTH_EXPORT int infoob_add_field(const char *name, int flags)
Creates a new field for updating system objects.
Definition: infoob.c:147
Definition: rttpd.h:80
char * name
Definition: rttpd.h:540
Definition: rttpd.h:73
unsigned short sessions
Definition: rttpd.h:624
time_t s_connected
Definition: rttpd.h:506
user_t * user
Definition: rttpd.h:504
AUTH_EXPORT int auth_create_object(char *name, object_type_t type)
Create an object within the Liberator.
Definition: auth.c:6041
int ref
Definition: rttpd.h:404
Definition: rttpd.h:86
object_type_t type
Definition: rttpd.h:541
The RTTP Session Object.
Definition: rttpd.h:500
char * application_id
Definition: rttpd.h:512
Definition: rttpd.h:145
unsigned long s_updates
Definition: rttpd.h:508
unsigned short max_sessions
Definition: rttpd.h:625
short msg
Definition: rttpd.h:582
Definition: rttpd.h:76
AUTH_EXPORT int auth_eject_sessions_by_app_id(user_t *user, int num, char *app_id)
Eject sessions with matching application id.
Definition: auth.c:2131
Callback that is called when an object changes initial state.
Definition: rttpd.h:538
AUTH_EXPORT int auth_get_login_count(char *username)
Get the number of current logins for a username.
Definition: auth.c:6213
AUTH_EXPORT void auth_invalidate_object(char *name, int flags)
Invalidate an object.
Definition: auth.c:2409
_auth_result
Return codes for the authentication functions.
Definition: rttpd.h:119
void * auth
Definition: rttpd.h:505
AUTH_EXPORT int auth_get_user_session_count_by_name(char *object_name)
Return the number of active sessions.
Definition: auth.c:5986
AUTH_EXPORT size_t auth_get_extra_data(char *token, char *buffer, size_t max_len)
Gets the extra data from the token. The extra data is expected to be the 4th part of the ~ separated ...
Definition: auth.c:6248
AUTH_EXPORT void auth_delete_object(char *name)
Delete an object within the Liberator.
Definition: auth.c:6069
AUTH_EXPORT void auth_unsubscribe(int subscriptionId)
Unsubscribes to subject.
Definition: auth.c:6389
char * username
Definition: rttpd.h:402
Definition: rttpd.h:82
AUTH_EXPORT void auth_set_tobouser(const char *username, const char *tobouser)
Set the tobo user for the specified user.
Definition: auth.c:5877
char * machine_id
Definition: rttpd.h:513
The map information object.
Definition: rttpd.h:579
AUTH_EXPORT char * auth_get_token_parameter(const char *keymaster_token, const char *parameter_to_query)
Return a value for the given field within a keymaster token.
Definition: auth.c:5843
The RTTP node object.
Definition: rttpd.h:621
AUTH_EXPORT void infoob_add_int(object_t *obj, int field, int value)
Adds a numerical value to a system object.
Definition: infoob.c:274
AUTH_EXPORT int auth_eject_sessions(user_t *user, int num)
Eject sessions.
Definition: auth.c:2030
AUTH_EXPORT int auth_eject_username_by_machine_id(char *name, int num, char *machine_id)
Wrapper for auth_eject_sessions_by_machine_id that takes the user name instead of a _user pointer...
Definition: auth.c:2225
char * auth_filename_expand(char *format, char *buf, size_t buflen)
Expand a a filename pattern into a fully qualified filename.
Definition: auth.c:6027
Definition: rttpd.h:79
AUTH_EXPORT void infoob_add_str_generic(object_t *obj, const char *fieldname, const char *value)
Adds a value to a system object.
Definition: infoob.c:325
AUTH_EXPORT int auth_eject_sessions_by_machine_id(user_t *user, int num, char *machine_id)
Eject sessions based on the username by machine id.
Definition: auth.c:2281
Structure passed between invalidation routines.
Definition: rttpd.h:566
char type
Definition: rttpd.h:511
Definition: rttpd.h:81
#define SESSION_ID_LEN_MAX
Definition: rttpd.h:481
void * auth
Definition: rttpd.h:542
AUTH_EXPORT void auth_session_throttle(char *session_id, char *command)
Throttle a users&#39; session.
Definition: auth.c:2465

Generated on Wed Apr 29 2020 16:49:51 for Liberator Auth API