00001 /* ==================================================================== 00002 * The Kannel Software License, Version 1.0 00003 * 00004 * Copyright (c) 2001-2008 Kannel Group 00005 * Copyright (c) 1998-2001 WapIT Ltd. 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * 1. Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in 00017 * the documentation and/or other materials provided with the 00018 * distribution. 00019 * 00020 * 3. The end-user documentation included with the redistribution, 00021 * if any, must include the following acknowledgment: 00022 * "This product includes software developed by the 00023 * Kannel Group (http://www.kannel.org/)." 00024 * Alternately, this acknowledgment may appear in the software itself, 00025 * if and wherever such third-party acknowledgments normally appear. 00026 * 00027 * 4. The names "Kannel" and "Kannel Group" must not be used to 00028 * endorse or promote products derived from this software without 00029 * prior written permission. For written permission, please 00030 * contact org@kannel.org. 00031 * 00032 * 5. Products derived from this software may not be called "Kannel", 00033 * nor may "Kannel" appear in their name, without prior written 00034 * permission of the Kannel Group. 00035 * 00036 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00037 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00038 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00039 * DISCLAIMED. IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS 00040 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 00041 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00042 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 00043 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00044 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00045 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00046 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00047 * ==================================================================== 00048 * 00049 * This software consists of voluntary contributions made by many 00050 * individuals on behalf of the Kannel Group. For more information on 00051 * the Kannel Group, please see <http://www.kannel.org/>. 00052 * 00053 * Portions of this software are based upon software originally written at 00054 * WapIT Ltd., Helsinki, Finland for the Kannel project. 00055 */ 00056 00057 /* 00058 * wap_push_ppg_pushuser.h: Header of the push user module. This means 00059 * currently authentication and smsc routing. 00060 * 00061 * Only WAP-165-PushArchOverview-19991108-a, an informal document, mentions 00062 * pi authentication. (See chapter 13.) So this is definitely left for 00063 * implementors. 00064 * Basic authentication is defined in rfc 2617. Note that https connections 00065 * are handled by our http module. 00066 * 00067 * By Aarno Syvänen for Wiral Ltd and Global Networks Inc 00068 */ 00069 00070 #ifndef WAP_PUSH_PPG_PUSHUSER_H 00071 #define WAP_PUSH_PPG_PUSHUSER_H 00072 00073 #include "gwlib/gwlib.h" 00074 00075 /* 00076 * This function initializes the module and push users data stucture, contain- 00077 * ing user specific data for all push user accounts. This function MUST be 00078 * called before any other functions of this module. 00079 */ 00080 int wap_push_ppg_pushuser_list_add(List *l, long number_of_pushes, 00081 long number_of_users); 00082 00083 /* 00084 * This function does clean up for module shutdown. This module MUST be called 00085 * when the caller of this module is shut down. 00086 */ 00087 void wap_push_ppg_pushuser_list_destroy(void); 00088 00089 /* 00090 * This function does authentication possible before compiling the control 00091 * document. This means: 00092 * a) password authentication by url or by headers (it is, by basic 00093 * authentication response, see rfc 2617, chapter 2) 00094 * b) if this does not work, basic authentication by challenge - 00095 * response 00096 * c) enforcing various ip lists 00097 * 00098 * Check does ppg allows a connection from this at all, then try to find username 00099 * and password from headers, then from url. If both fails, try basic authentica- 00100 * tion. Then check does this user allow a push from this ip, then check the pass- 00101 * word. 00102 * 00103 * For protection against brute force and partial protection for denial of serv- 00104 * ice attacks, an exponential backup algorithm is used. Time when a specific ip 00105 * is allowed to reconnect, is stored in Dict next_try. If an ip tries to recon- 00106 * nect before this (three attemps are allowed, then exponential seconds are add- 00107 * ed to the limit) we make a new challenge. We do the corresponding check before 00108 * testing passwords; after all, it is an authorization failure that causes a new 00109 * challenge. 00110 * 00111 * Rfc 2617, chapter 1 states that if we do not accept credentials of an user's, 00112 * we must send a new challenge to the user. 00113 * 00114 * Output an authenticated username. 00115 * This function should be called only when there are a push users list; the 00116 * caller is responsible for this. 00117 */ 00118 int wap_push_ppg_pushuser_authenticate(HTTPClient *client, List *cgivars, 00119 Octstr *ip, List *headers, 00120 Octstr **username); 00121 00122 /* 00123 * This function checks phone number for allowed prefixes, black lists and 00124 * white lists. Note that the phone number necessarily follows the interna- 00125 * tional format (this is checked by our pap compiler). 00126 */ 00127 int wap_push_ppg_pushuser_client_phone_number_acceptable(Octstr *username, 00128 Octstr *number); 00129 00130 int wap_push_ppg_pushuser_search_ip_from_wildcarded_list(Octstr *haystack, 00131 Octstr *needle, Octstr *gwlist_sep, Octstr *ip_sep); 00132 00133 /* 00134 * Returns smsc pushes by this user must use, or NULL when error. 00135 */ 00136 Octstr *wap_push_ppg_pushuser_smsc_id_get(Octstr *username); 00137 00138 /* 00139 * Returns default dlr url for this user, or NULL when error. 00140 */ 00141 Octstr *wap_push_ppg_pushuser_dlr_url_get(Octstr *username); 00142 00143 /* 00144 * Returns default dlr smsbox id for this user, or NULL when error. 00145 */ 00146 Octstr *wap_push_ppg_pushuser_smsbox_id_get(Octstr *username); 00147 #endif