Liberator Auth API  6.2.25.313361
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 "6.2.25"
13 
14 #define RTTPD_MAJOR_VERSION 6
15 #define RTTPD_MINOR_VERSION 2
16 #define RTTPD_PATCH_VERSION 25
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 };
88 
89 typedef enum _object_type object_type_t;
90 
91 
111 char *auth_filename_expand(char *format, char *buf, size_t buflen);
112 
113 
119 {
120  AUTH_AGAIN = 2,
121  AUTH_DELAYED = 1,
122  AUTH_OK = 0,
123  AUTH_DENY = -1,
124  AUTH_FALSE = -2,
125  AUTH_INVALID_USER = -3,
126  AUTH_INVALID_PASS = -4,
127  AUTH_INVALID_ADDR = -5,
128  AUTH_ACCT_EXPIRED = -6,
129  AUTH_USER_LC_EXCEEDED = -7,
130  AUTH_SITE_LC_EXCEEDED = -8,
131  AUTH_ERROR = -9,
132  AUTH_USER1 = -99,
133  AUTH_USER2 = -98,
134  AUTH_USER3 = -97,
135  AUTH_USER4 = -96,
136  AUTH_USER5 = -95,
137 };
138 
139 typedef enum _auth_perm_operation auth_perm_operation_t;
140 
141 
145 {
149 };
150 
151 typedef struct _auth_map_type auth_map_t;
152 
153 struct _auth_map_type
154 {
155  char* key;
156  char* value;
157 };
158 
159 typedef enum _http_method http_method_t;
160 
161 enum _http_method
162 {
163  M_HTTP_GET = 1,
164  M_HTTP_HEAD = 2,
165  M_HTTP_POST = 3,
166  M_HTTP_PUT = 4,
167  M_HTTP_DELETE = 5,
168 };
169 
170 
176 {
177  int (*auth_new_user)(session_t *session, char *user, char *pass);
178 
192  int (*auth_free_user)(session_t *session);
193 
201  int (*auth_new_object)(object_t *obj, object_t *parent);
202 
213  int (*auth_free_object)(object_t *obj);
214 
224  int (*auth_check_read)(session_t *session, object_t *obj);
225 
244  int (*auth_check_write)(session_t *session, object_t *obj);
245 
265  int (*auth_map_object)(session_t *session, char *name, char *mapped, int *len);
266 
285  int (*auth_request_object)(session_t *session, object_t *obj);
286 
298  int (*auth_discard_object)(session_t *session, object_t *obj);
299 
311  int (*auth_http_request)(char *user, char *pass, http_method_t method, char *path);
312 
327  int (*auth_check_update)(session_t *session, object_t *obj, char *data);
328 
344  int (*auth_check_permission_update)(session_t *session, object_t *obj, char *key, int auth_map_size, auth_map_t *keyvalues);
345  void (*auth_exit)();
346 
349  int (*auth_check_write_extended)(session_t *session, object_t *obj, int field_count, string_pair_t * fields, char *contrib_id);
350 
373  void (*auth_global_permission_update)(object_t *obj, char *key, int auth_map_size, auth_map_t *keyvalues, auth_perm_operation_t operation);
374 
384 };
385 
386 
395 struct _user
396  {
397  char *username;
398  char *password;
399  int ref;
400  void *auth;
401  };
402 
403 struct _string_pair_type
404 {
405  char* name;
406  char* value;
407 };
408 
409 AUTH_EXPORT int auth_eject_sessions(user_t *user, int num);
410 
411 AUTH_EXPORT int auth_eject_sessions_by_app_id(user_t *user, int num, char *app_id);
412 
413 AUTH_EXPORT int auth_eject_sessions_by_machine_id(user_t *user, int num, char *machine_id);
414 
415 AUTH_EXPORT void auth_invalidate_sessions(user_t *user, int num, int flags);
416 
417 AUTH_EXPORT void auth_invalidate_sessions_by_name(char *name, int num, int flags);
418 
419 AUTH_EXPORT void auth_invalidate_all_sessions(int flags);
420 
421 AUTH_EXPORT void auth_invalidate_object(char *name, int flags);
422 
423 AUTH_EXPORT int signature_check(char *key_id, char *token);
424 
425 AUTH_EXPORT void auth_session_throttle(char *session_id, char *command);
426 
427 AUTH_EXPORT void auth_listener_throttle(char *session_id, char * object_name, char *command);
428 
429 AUTH_EXPORT int auth_get_user_session_count_by_name(char * object_name);
430 
431 AUTH_EXPORT int auth_eject_username_sessions(char *name, int num);
432 
433 AUTH_EXPORT int auth_eject_username_by_app_id(char *name, int num, char *app_id);
434 
435 AUTH_EXPORT int auth_eject_username_by_machine_id(char *name, int num, char *machine_id);
436 
437 AUTH_EXPORT int auth_create_object(char *name, object_type_t type);
438 
439 AUTH_EXPORT void auth_delete_object(char *name);
440 
441 AUTH_EXPORT int auth_verify_signature_username(char *expected_username, char *token);
442 
443 AUTH_EXPORT int auth_get_login_count(char *username);
444 
445 AUTH_EXPORT size_t auth_get_extra_data(char *token, char *buffer, size_t max_len);
446 
447 AUTH_EXPORT char *auth_get_token_parameter(const char *keymaster_token, const char *parameter_to_query);
448 
449 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));
450 
451 AUTH_EXPORT void auth_subscribe(int subscriptionId);
452 
453 AUTH_EXPORT void auth_unsubscribe(int subscriptionId);
454 
455 
457 #define SESSION_ID_LEN_MIN 6
458 
459 
461 #define SESSION_ID_LEN_DEFAULT 12
462 
463 
465 #define SESSION_ID_LEN_MAX 256
466 
467 
469 typedef struct _session_request_retry session_request_retry_t;
470 
471 
484 struct _session
485 {
486  char id[SESSION_ID_LEN_MAX+1];
487  int uid;
489  void *auth;
490  time_t s_connected;
491  time_t s_loggedin;
492  unsigned long s_updates;
493  struct sockaddr_in addr;
494  char *addrname;
495  char type;
497  char *machine_id;
498  char *cookie;
500 };
501 
502 typedef struct _fieldset fieldset_t;
503 
504 
522 struct _object
523 {
524  char *name;
525  object_type_t type;
526  void *auth;
527 };
528 
529 enum
530 {
531  THREADS_AUTH_LOGIN = 600,
532  THREADS_AUTH_MAPPED = 601,
533  THREADS_AUTH_CHECKWRITE = 602
534 };
535 
536 
551 {
552  char session_id[SESSION_ID_LEN_MAX+1];
553  short msg;
554 };
555 
556 
563 struct _mapinfo
564 {
565  char session_id[SESSION_ID_LEN_MAX+1];
566  short msg;
567  char name[MAX_OBNAME+1];
568  char mapped[MAX_OBNAME+1];
569 };
570 
571 struct _checkwriteinfo
572 {
573  char session_id[SESSION_ID_LEN_MAX+1];
574  short msg;
575  char name[MAX_OBNAME+1]; /* The name of the object that is being contributed to */
576  char contrib_id[5];
577 };
578 
579 AUTH_EXPORT char *object_get_value(object_t *obj, int32_t fieldnum, char *buf, int len);
580 
581 AUTH_EXPORT int infoob_add_field(const char *name, int flags);
582 
583 AUTH_EXPORT object_t *infoob_new_object(const char *name);
584 
585 AUTH_EXPORT void infoob_add_str(object_t *obj, int field, const char *value);
586 
587 AUTH_EXPORT void infoob_add_int(object_t *obj, int field, int value);
588 
589 AUTH_EXPORT void infoob_add_data(object_t *obj, const int *fields, const char **values, int count);
590 
591 
597 struct _nodeinfo
598  {
599  char *nodename;
600  unsigned short sessions;
601  unsigned short max_sessions;
602  };
603 
604 
605 #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:2024
char * authorization
Definition: rttpd.h:499
Describes the callback functions that should be implemented by an auth module.
Definition: rttpd.h:175
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:5969
Definition: rttpd.h:74
The user object.
Definition: rttpd.h:395
Definition: rttpd.h:75
Definition: rttpd.h:78
char * addrname
Definition: rttpd.h:494
Definition: rttpd.h:77
AUTH_EXPORT void auth_invalidate_sessions(user_t *user, int num, int flags)
Invalidate all sessions for a user.
Definition: auth.c:2259
struct _session_request_retry session_request_retry_t
Structure used to hold request retry information when things are overloaded.
Definition: rttpd.h:469
AUTH_EXPORT object_t * infoob_new_object(const char *name)
Creates a new system object.
Definition: infoob.c:334
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:144
Definition: rttpd.h:83
int uid
Definition: rttpd.h:487
_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:2432
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:1926
short msg
Definition: rttpd.h:553
Definition: rttpd.h:148
AUTH_EXPORT void infoob_add_str(object_t *obj, int field, const char *value)
Adds a value to a system object.
Definition: infoob.c:399
AUTH_EXPORT void auth_subscribe(int subscriptionId)
Subscribes to subject.
Definition: auth.c:6128
time_t s_loggedin
Definition: rttpd.h:491
char * cookie
Definition: rttpd.h:498
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:1390
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:3849
Definition: rttpd.h:147
AUTH_EXPORT void auth_invalidate_all_sessions(int flags)
Invalidate all sessions for all users in the system.
Definition: auth.c:2355
void * auth
Definition: rttpd.h:400
char * nodename
Definition: rttpd.h:599
char * password
Definition: rttpd.h:398
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:484
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:6107
AUTH_EXPORT void auth_invalidate_sessions_by_name(char *name, int num, int flags)
Invalidate all sessions for a username.
Definition: auth.c:2296
AUTH_EXPORT int infoob_add_field(const char *name, int flags)
Creates a new field for updating system objects.
Definition: infoob.c:310
Definition: rttpd.h:80
char * name
Definition: rttpd.h:524
Definition: rttpd.h:73
unsigned short sessions
Definition: rttpd.h:600
time_t s_connected
Definition: rttpd.h:490
user_t * user
Definition: rttpd.h:488
AUTH_EXPORT int auth_create_object(char *name, object_type_t type)
Create an object within the Liberator.
Definition: auth.c:5856
int ref
Definition: rttpd.h:399
Definition: rttpd.h:86
object_type_t type
Definition: rttpd.h:525
The RTTP Session Object.
Definition: rttpd.h:484
char * application_id
Definition: rttpd.h:496
Definition: rttpd.h:146
unsigned long s_updates
Definition: rttpd.h:492
unsigned short max_sessions
Definition: rttpd.h:601
short msg
Definition: rttpd.h:566
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:2068
Callback that is called when an object changes initial state.
Definition: rttpd.h:522
AUTH_EXPORT int auth_get_login_count(char *username)
Get the number of current logins for a username.
Definition: auth.c:5995
AUTH_EXPORT void auth_invalidate_object(char *name, int flags)
Invalidate an object.
Definition: auth.c:2328
_auth_result
Return codes for the authentication functions.
Definition: rttpd.h:118
void * auth
Definition: rttpd.h:489
AUTH_EXPORT int auth_get_user_session_count_by_name(char *object_name)
Return the number of active sessions.
Definition: auth.c:5801
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:6030
AUTH_EXPORT void auth_delete_object(char *name)
Delete an object within the Liberator.
Definition: auth.c:5884
AUTH_EXPORT void auth_unsubscribe(int subscriptionId)
Unsubscribes to subject.
Definition: auth.c:6171
char * username
Definition: rttpd.h:397
Definition: rttpd.h:82
char * machine_id
Definition: rttpd.h:497
The map information object.
Definition: rttpd.h:563
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:5725
The RTTP node object.
Definition: rttpd.h:597
AUTH_EXPORT void infoob_add_int(object_t *obj, int field, int value)
Adds a numerical value to a system object.
Definition: infoob.c:440
AUTH_EXPORT int auth_eject_sessions(user_t *user, int num)
Eject sessions.
Definition: auth.c:1969
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:2160
char * auth_filename_expand(char *format, char *buf, size_t buflen)
Expand a a filename pattern into a fully qualified filename.
Definition: auth.c:5842
Definition: rttpd.h:79
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:2201
Structure passed between invalidation routines.
Definition: rttpd.h:550
char type
Definition: rttpd.h:495
Definition: rttpd.h:81
#define SESSION_ID_LEN_MAX
Definition: rttpd.h:465
void * auth
Definition: rttpd.h:526
AUTH_EXPORT void auth_session_throttle(char *session_id, char *command)
Throttle a users&#39; session.
Definition: auth.c:2384

Generated on Tue Nov 19 2019 10:18:21 for Liberator Auth API