From: Andrey C. <sku...@us...> - 2006-11-03 16:32:10
|
Update of /cvsroot/eas-dev/ocmng/EAS/security In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv6950/EAS/security Added Files: auth.prg auth.xml Log Message: Move all components to top level. Remove ocmng and xml2xmo sources. Add components: - dbconsole - form_menu, form_action and form_localization for menu generation - update form component for generation menu --- 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="koi8-r" 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-06-04</modified> <requires> <dependence type="component">../forms/form.xml</dependence> </requires> <author>Skull</author> <data> <objects depository="ETC0101" class="mng_form"> <object> <attr name="name">auth.po</attr> <attr name="type">application/x-clip-plugin</attr> <attr name="description">Authentication plugin</attr> <attr name="content">auth.po</attr> </object> </objects> <objects depository="ETC0101" class="mng_command"> <object> <attr name="name">authenticate</attr> <attr name="component_name">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> </object> </objects> </data> <locale lang="ru"> <name>auth</name> <description>áÕÔÅÎÔÉÆÉËÁÃÉÑ ÐÏÌØÚÏ×ÁÔÅÌÅÊ</description> </locale> </component> |