From: Andrey C. <sku...@us...> - 2006-06-02 14:44:55
|
Update of /cvsroot/eas-dev/ocmng/components/ocmng/security In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv17182/components/ocmng/security Added Files: auth.prg auth.xml Log Message: Add files --- NEW FILE: auth.prg --- /*-------------------------------------------------------------------------*/ /* E/AS Component (part of E/AS project) */ /* */ /* Copyright (C) 2005 by E/AS Software Foundation */ /* Author: Andrey Cherepanov <sk...@ea...> */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as */ /* published by the Free Software Foundation; either version 2 of the */ /* License, or (at your option) any later version. */ /*-------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------/ / / / Name: User authentication / / System name: auth / / Description: User authentication / / Version: 0.1 / / Author: Andrey Cherepanov <sk...@ea...> / / / / Available commands: / / AUTH Authenticate user / / <params> Authenticate parameters / / / /--------------------------------------------------------------------------*/ #define DEFAULT_AUTH_METHOD 'PAM' /** Component: auth */ parameters cMethod, params local cContent:='' local oErr, i, err:='' local authMethod := DEFAULT_AUTH_METHOD, cfg local cCmd, cStdOut:=space(0), cStdErr:=space(0) local user, password, authString eDebug(12, "AUTH method:", cMethod, params) oErr := ErrorBlock({|e| break(e) }) begin sequence /*=========================================================================*/ // AUTH() if lower(cMethod) == 'authenticate' cfg := EASGetConfig() cMethod := cfg:getValue('AUTH','METHOD') if .not. empty(cMethod) authMethod := cMethod endif // PAM authentication if upper(cMethod) == 'PAM' cCmd := cfg:getValue('AUTH','PAM') // Substitute CLIPROOT if neccessary cCmd := strtran(cCmd, '$CLIPROOT', getenv("CLIPROOT")) if empty(cCmd) .or. .not. file(cCmd) eDebug(2, "AUTH: file not found:", cCmd) return .F. endif params := params:params if assertParameters( params, { 'name:C', 'password:C' } ) eDebug(2, "AUTH: internal error: missing parameter 'name' and/or 'password'") return .F. endif authString := params:name+" "+params:password+"&\n" syscmd(cCmd, authString, @cStdOut, @cStdErr) //if ( syscmd(cCmd, authString, @cStdOut, @cStdErr) != 0 ) //eDebug(2, "AUTH executable error:",cCmd) //return .F. //endif eDebug(2, "AUTH result:",cStdOut) if left(cStdOut,2) == "OK" eDebug(12, "AUTH: access granted for", params:name) return .T. // Access granted else eDebug(12, "AUTH: access denied for", params:name) return .F. // Access denied endif endif endif recover using oErr i := 1 while ( !empty(ProcName(i)) ) err += "Called from "+allTrim(ProcName(i)) + ; ":" + alltrim(str(ProcLine(i))) + chr(10) i++ end eDebug(5, "Component internal error:", errorMessage(oErr)) return NIL end sequence return .F. --- NEW FILE: auth.xml --- <?xml version="1.0" encoding="utf-8" standalone="no" ?> <component> <name>auth</name> <category>Core/Security</category> <version>0.1</version> <description>User authentication</description> <license>GNU/GPL</license> <created>2006-04-23</created> <modified>2006-05-19</modified> <requires> <dependence type="component">../ocmng/components</dependence> <dependence type="component">../forms/form</dependence> </requires> <author> <name>Andrey Cherepanov</name> <email>sk...@ea...</email> <copyright>2006</copyright> </author> <files> <file name="auth.po">Authentication plugin</file> </files> <data> <objects depository="ETC0101" class="mng_command"> <object> <attr name="name">authenticate</attr> <attr name="component" refTo="ETC0101:mng_component">auth</attr> <attr name="form" refTo="ETC0101:mng_form">auth.po</attr> <attr name="description"><![CDATA[Authenticate user. Arguments: method - String. Authentication method. Default: 'PAM'. params - Map. Parameters (name:C,password:C). Returns: Logical. .T. if access is granted.]]></attr> <attr name="enabled">true</attr> </object> </objects> </data> <locale lang="ru"> <name>auth</name> <description>ÐÑÑенÑиÑикаÑÐ¸Ñ Ð¿Ð¾Ð»ÑзоваÑелей</description> </locale> </component> |