Received: from bush.rutgersinsurance.com (rutgersinsurance.com [38.138.71.194]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eA2GFil37887 for ; Thu, 2 Nov 2000 11:15:44 -0500 (EST) (envelope-from aalang@rutgersinsurance.com) Received: from 6014cwpza006 ([10.10.10.51]) by bush.rutgersinsurance.com (8.9.3/8.9.3) with SMTP id LAA08074 for ; Thu, 2 Nov 2000 11:20:34 -0500 Message-ID: <002801c044e8$780a0d40$330a0a0a@6014cwpza006> From: "Adam Lang" To: References: Subject: Re: Connecting remotely - multi tier Date: Thu, 2 Nov 2000 11:17:55 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200011/43 X-Sequence-Number: 79 Ok... so if I am writing a distributed application in windows that will use a Postgresql backend, I should have the client interface another "server" application, which will inturn access/retrieve informaton from the database? Well, how about this... I have a VB client application that uses a NT server VB application for the middle tier, and the postgresql database is on a linux server. Is it ok THEN to wrap the libpq into a dll and COM object for the middle tier to access the database, as oppsoed to using ODBC? In essence that is what I was asking... the possibility a Postgresql API that I could use, as opposed to a generalised ODBC driver. Whether for a client or a middle tier, it doesn't matter. Adam Lang Systems Engineer Rutgers Casualty Insurance Company ----- Original Message ----- From: "Sergio A. Kessler" To: ; Sent: Thursday, November 02, 2000 10:03 AM Subject: Re: [INTERFACES] Connecting remotely - multi tier > Cedar Cox el día Thu, 2 Nov 2000 17:18:48 +0200 > (IST), escribió: > > >You seem to have given this a lot of thought so let me ask a question. > >How do I implement a user login system? If the user knows their password > >(and don't they always?..), what's to stop them from finding and > >contacting the database directly, bypassing the middle tier? > > because you setup the database (ie. pg_hba.conf) so that ONLY and only > the machine thas has the middle tier can connect to the database directly, > no other machine in the world can conect to the databse bypassing the > middle tier (even if the user know all passwords). > > > I haven't > >been able to find a solution to this problem. Every time I try to think > >about it by brain goes into a recursive loop! :o > > this is what I've done: > > I implemented a login system with php (using http authentication), > so the machine running apache and php (the only machine with direct > access to the db) connect with with the db with the username & password > in behalf of the user. > > this is my routine: > > function sak_db_auth() > { > global $db_conf; > global $PHP_AUTH_USER; > global $PHP_AUTH_PW; > > // header("Cache-Control: no-cache"); > // header("Pragma: no-cache"); > header("Expires: Sat, Jan 01 2000 01:01:01 GMT"); > > function login_prompt() > { > global $db_conf; > header("WWW-Authenticate: Basic realm=\"" . $db_conf["realm"] . "\""); > header("HTTP/1.0 401 Unauthorized"); > echo ""; > exit; > } > > if (!isset($PHP_AUTH_USER)) { > login_prompt(); > } else > { > if($PHP_AUTH_USER && $PHP_AUTH_PW) > { > if (!in_array($PHP_AUTH_USER, $db_conf["allowed_users"])) > { > return(false); > } > > $db_conf["user"] = $PHP_AUTH_USER; > $db_conf["password"] = $PHP_AUTH_PW; > $db_conf["str_conn"] = "dbname=" . $db_conf["dbname"] . " user=" . > $db_conf["user"] . " password=" . $db_conf["password"]; > > $db = @pg_connect($db_conf["str_conn"]); > > if (!$db) { > $result = false; > } else { > pg_close($db); > $result = true; > } > } > } > return($result); > } > > in this way the users cannot connect directly to the db with crap > like access, excel and so on .. > > >On Wed, 1 Nov 2000, Sergio A. Kessler wrote: > > > >> "Adam Lang" el día Wed, 1 Nov 2000 09:52:35 > >> -0500, escribió: > >> > >> [...] > >> > > >> >What are people's thoughts? > >> > >> people's thoughts are that you really want to design a multi-thier > >> design (for example a 3 layer design), where > >> > >> / client1 (browser) > >> database <---> bussines rules - client2 (browser) > >> (ie. apache, php,...) \ ..... > >> > >> > >> if your client has direct access to the database, you design is broken... > >> > >> sergio > >> > >>