1 /* 2 * libwebsockets - small server side websockets and web server implementation 3 * 4 * Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com> 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to 8 * deal in the Software without restriction, including without limitation the 9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 * sell copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 * IN THE SOFTWARE. 23 */ 24 25 /*! \defgroup generic-sessions plugin: generic-sessions 26 * \ingroup Protocols-and-Plugins 27 * 28 * ##Plugin Generic-sessions related 29 * 30 * generic-sessions plugin provides a reusable, generic session and login / 31 * register / forgot password framework including email verification. 32 */ 33 ///@{ 34 35 #define LWSGS_EMAIL_CONTENT_SIZE 16384 36 /**< Maximum size of email we might send */ 37 38 /* SHA-1 binary and hexified versions */ 39 /** typedef struct lwsgw_hash_bin */ 40 typedef struct { unsigned char bin[32]; /**< binary representation of hash */} lwsgw_hash_bin; 41 /** typedef struct lwsgw_hash */ 42 typedef struct { char id[65]; /**< ascii hex representation of hash */ } lwsgw_hash; 43 44 /** enum lwsgs_auth_bits */ 45 enum lwsgs_auth_bits { 46 LWSGS_AUTH_LOGGED_IN = 1, /**< user is logged in as somebody */ 47 LWSGS_AUTH_ADMIN = 2, /**< logged in as the admin user */ 48 LWSGS_AUTH_VERIFIED = 4, /**< user has verified his email */ 49 LWSGS_AUTH_FORGOT_FLOW = 8, /**< just completed "forgot password" */ 50 }; 51 52 /** struct lws_session_info - information about user session status */ 53 struct lws_session_info { 54 char username[32]; /**< username logged in as, or empty string */ 55 char email[100]; /**< email address associated with login, or empty string */ 56 char ip[72]; /**< ip address session was started from */ 57 unsigned int mask; /**< access rights mask associated with session 58 * see enum lwsgs_auth_bits */ 59 char session[42]; /**< session id string, usable as opaque uid when not logged in */ 60 }; 61 62 /** enum lws_gs_event */ 63 enum lws_gs_event { 64 LWSGSE_CREATED, /**< a new user was created */ 65 LWSGSE_DELETED /**< an existing user was deleted */ 66 }; 67 68 /** struct lws_gs_event_args */ 69 struct lws_gs_event_args { 70 enum lws_gs_event event; /**< which event happened */ 71 const char *username; /**< which username the event happened to */ 72 const char *email; /**< the email address of that user */ 73 }; 74 75 ///@} 76