On Tuesday 22 June 2004 19:41, Robert Kehl wrote:
> On Tuesday, June 22, 2004 9:50 AM
>
> Dmitriy Borisov <[EMAIL PROTECTED]> wrote:
> > I`d change source of OTRS for my needs. I think, that it can be
> > useful for other. So, I posting it in this list.
>
> Sorry, but could I get you to describe what the changes are doing, and
> provide a patch instead of the whole file(s)? Please use
>
> # cd /opt/otrs
> # diff -bru Kernel/System/CustomerAuth/DB.pm.orig
> Kernel/System/CustomerAuth/DB.pm > DB.pm.patch
OK. I attach patch files to this letter. I`m working with OTRS version 1.1.3,
but this patch describes difference between my patched version of OTRS and
OTRS version 1.2.3 sources. In patch files some new things are
disabled because of my old sources.
My version of DB.pm is wrote because I got to only authenticate my customers with
external database. And I think, that with this patch "New customer" and
"Change customer password" features will not work correctly. Exactly, they must not
work
correctly :( May be in future I`ll add support of changing this options in other
modules.
In my version of OTRS all operations with CustomerPreferences and Customer
authenticate options must be disabled because I have external interface to work.
I`d disabled they by changing forms to hide this options from customer. This changes
I`m not posting to you because it is simple and I think that only some peoples can
have
need for they. But I can to do it if it is important.
Changes in Config.pm was wrote to provide future configure capability with other
modules of OTRS. There are none difference with describing options for
CustomerUser preferences of Config.pm.dist in Config.pm file.
Changes in Kernel/System//CustomerAuth/DB.pm was wrote to provide
authentication of my users with external database. There had changes made in
SQL query to database (using parameters from Config.pm) and in new routine to
import options from Config object to this CustomerAuth::DB object. Changes, that
I was made, include an unencrypted password verification because passwords in my
database are stored in unencrypted format.
I think, that all changes that I make can be useful for users, that have own customer
database and want to integrate OTRS system in there customer workspace.
Again, sorry for my English, it isn`t my native language
--
With best regards,
Dmitriy Borisov
Network administrator of INTS ISP
Ukraine, Donetsk
E-mail: [EMAIL PROTECTED]
--- Config.pm.dist Thu Jan 22 21:52:20 2004
+++ Config.pm Tue Jun 22 20:45:44 2004
@@ -2,7 +2,7 @@
# Kernel/Config.pm - Config file for OTRS kernel
# Copyright (C) 2001-2003 Martin Edenhofer <[EMAIL PROTECTED]>
# --
-# $Id: Config.pm.dist,v 1.9 2004/01/22 19:52:20 martin Exp $
+# $Id: Config.pm.dist,v 1.6 2003/03/02 08:56:36 martin Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
@@ -34,7 +34,7 @@
# ---------------------------------------------------- #
# SecureMode
# (Enable this so you can't use the installer.pl)
- $Self->{SecureMode} = 0;
+ $Self->{SecureMode} = 1;
# SystemID
# (The identify of the system. Each ticket number and
# each http session id starts with this number)
@@ -45,14 +45,14 @@
$Self->{TicketHook} = 'Ticket#';
# FQDN
# (Full qualified domain name of your system.)
- $Self->{FQDN} = 'yourhost.example.com';
+ $Self->{FQDN} = 'duty.ints.net';
# AdminEmail
# (Email of the system admin.)
- $Self->{AdminEmail} = '[EMAIL PROTECTED]';
+ $Self->{AdminEmail} = '[EMAIL PROTECTED]';
# Organization
# (If this is anything other than '', then the email will have an
# Organization X-Header)
- $Self->{Organization} = 'Example Company';
+ $Self->{Organization} = 'INTS';
# ---------------------------------------------------- #
# database settings #
@@ -65,33 +65,20 @@
$Self->{Database} = 'otrs';
# DatabaseUser
# (The database user.)
- $Self->{DatabaseUser} = 'otrs';
+ $Self->{DatabaseUser} = 'otrs_db';
# DatabasePw
# (The password of database user.)
- $Self->{DatabasePw} = 'some-pass';
+ $Self->{DatabasePw} = 'Pq3nV09';
# DatabaseDSN
# (The database DSN for MySQL ==> more: "man DBD::mysql")
$Self->{DatabaseDSN} = "DBI:mysql:database=$Self->{Database};host=$Self->{DatabaseHost};";
# (The database DSN for PostgrSQL ==> more: "man DBD::Pg")
# $Self->{DatabaseDSN} = "DBI:Pg:dbname=$Self->{Database};";
- # (The database DSN for Oracle ==> more: "man DBD::oracle")
-# $Self->{DatabaseDSN} = "DBI:Oracle:sid=$Self->{Database};host=$Self->{DatabaseHost};port=1521;";
- # if needed, oracle env settings
-# $ENV{ORACLE_HOME} = '/opt/ora9/product/9.2';
-# $ENV{NLS_DATE_FORMAT} = 'YYYY-MM-DD HH24:MI:SS';
-# $ENV{NLS_LANG} = "german_germany.we8iso8859p15";
-
- # (The database DSN for DBI:ODBC ==> more: "man DBD::ODBC")
-# $Self->{DatabaseDSN} = "DBI:ODBC:$Self->{Database}";
- # If you use ODBC, no database auto detection is possible,
- # so set the database type here. Possible: mysq,postgresql,oracle,sapdb
-# $Self->{'Database::Type'} = 'sapdb';
-
# ---------------------------------------------------- #
# fs root directory
# ---------------------------------------------------- #
- $Self->{Home} = '/opt/otrs';
+ $Self->{Home} = '/usr/local/otrs';
# **************************************************** #
# insert your own config settings "here" #
@@ -105,6 +92,105 @@
# data inserted by installer #
# ---------------------------------------------------- #
# $DIBI$
+ $Self->{TicketNumberGenerator} = 'Kernel::System::Ticket::Number::DateChecksum';
+ $Self->{LogModule::LogFile} = '/var/log/otrs.log';
+ $Self->{LogModule} = 'Kernel::System::Log::SysLog';
+ $Self->{DefaultLanguage} = 'ru';
+ $Self->{DefaultCharset} = 'koi8-r';
+ $Self->{CheckMXRecord} = 1;
+
+ # --------------------------------------------------- #
+ # #
+ # Start of config options!!! #
+ # CustomerUser stuff #
+ # #
+ # --------------------------------------------------- #
+
+ # ShowCustomerInfo*
+ # (show customer user info on Phone, Zoom and Queue view)
+ $Self->{ShowCustomerInfoPhone} = 1;
+ $Self->{ShowCustomerInfoZoom} = 1;
+ $Self->{ShowCustomerInfoQueue} = 0;
+
+ # ShowCustomerInfo*MaxSize
+ # (max size (in characters) of customer info table)
+ $Self->{ShowCustomerInfoPhoneMaxSize} = 18;
+ $Self->{ShowCustomerInfoZoomMaxSize} = 18;
+ $Self->{ShowCustomerInfoQueueMaxSize} = 15;
+
+ # CustomerUser
+ # (customer user database backend and settings)
+ $Self->{CustomerUser} = {
+ Module => 'Kernel::System::CustomerUser::DB',
+ Params => {
+# DSN => 'DBI:Pg:dbname=external_db;host=your.host.name',
+# User => 'user',
+# Password => 'password',
+ Table => 'abonsdata_for_otrs'
+ },
+ # customer uniq id
+ CustomerKey => 'login',
+ # customer #
+ CustomerID => 'customer_id',
+ CustomerValid => 'valid_id',
+ CustomerUserListFields => ['login', 'firm_sh', 'email'],
+ CustomerUserListFields => ['login', 'firm_sh', 'customer_id', 'email'],
+ CustomerUserSearchFields => ['login', 'firm_sh', 'customer_id'],
+ CustomerUserPostMasterSearchFields => ['email'],
+ CustomerUserNameFields => ['firm_sh'],
+ ReadOnly => 1,
+ Map => [
+ # note: Login, Email and CustomerID needed!
+ # var, frontend, storage, shown, required, storage-type, http-link
+# [ 'UserSalutation', 'Salutation', 'salutation', 1, 0, 'var' ],
+# [ 'UserFirstname', 'Firstname', 'first_name', 1, 1, 'var' ],
+# [ 'UserLastname', 'Lastname', 'last_name', 1, 1, 'var' ],
+ [ 'UserLogin', 'Login', 'login', 1, 1, 'var' ],
+ [ 'UserPassword', 'Password', 'pw', 0, 1, 'var' ],
+ [ 'UserEmail', 'Email', 'email', 0, 1, 'var' ],
+# [ 'UserEmail', 'Email', 'email', 1, 1, 'var', '$Env{"CGIHandle"}?Action=AgentCompose&ResponseID=1&TicketID=$Data{"TicketID"}&ArticleID=$Data{"ArticleID"}' ],
+ [ 'UserCustomerID', 'CustomerID', 'customer_id', 0, 1, 'var' ],
+ [ 'UserComment', 'Comment', 'firm_sh', 1, 0, 'var' ],
+ [ 'ValidID', 'Valid', 'valid_id', 0, 1, 'int' ],
+ ],
+ };
+
+ # --------------------------------------------------- #
+ # #
+ # Start of config options!!! #
+ # CustomerAuth stuff #
+ # #
+ # --------------------------------------------------- #
+
+ $Self->{'Customer::AuthModule'} = 'Kernel::System::CustomerAuth::DB';
+
+ # CustomerAuth
+ # (customer auth database backend and settings)
+ $Self->{CustomerAuth} = {
+ Module => 'Kernel::System::CustomerAuth::DB',
+ Params => {
+# DSN => 'DBI:Pg:dbname=external_db;host=your.host.name',
+# User => 'user',
+# Password => 'password',
+ Table => 'abons_for_otrs'
+ },
+ # customer #
+ CustomerID => 'customer_id',
+ ValidID => 'valid_id',
+ CustomerAuthUserField => 'login',
+ CustomerAuthPwField => 'pw',
+ ReadOnly => 1,
+ Map => [
+# # note: Login, Email and CustomerID needed!
+# # var, frontend, storage, shown, required, storage-type, http-link
+# [ 'UserLastname', 'Lastname', 'firm_sh', 1, 1, 'var' ],
+ [ 'UserLogin', 'Login', 'login', 1, 1, 'var' ],
+ [ 'UserPassword', 'Password', 'pw', 0, 1, 'var' ],
+# [ 'UserEmail', 'Email', 'email', 0, 1, 'var' ],
+ [ 'UserCustomerID', 'CustomerID', 'customer_id', 0, 1, 'var' ],
+ [ 'ValidID', 'Valid', 'valid_id', 0, 1, 'int' ],
+ ],
+ };
# ---------------------------------------------------- #
# ---------------------------------------------------- #
@@ -122,7 +208,7 @@
use vars qw(@ISA $VERSION);
use Kernel::Config::Defaults;
push (@ISA, 'Kernel::Config::Defaults');
-$VERSION = '$Revision: 1.9 $';
+$VERSION = '$Revision: 1.6 $';
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;
# -----------------------------------------------------#
--- DB_new.pm Fri Feb 13 02:50:36 2004
+++ DB.pm Tue Jun 22 20:47:37 2004
@@ -1,8 +1,8 @@
# --
# Kernel/System/CustomerAuth/DB.pm - provides the db authentification
-# Copyright (C) 2001-2004 Martin Edenhofer <[EMAIL PROTECTED]>
+# Copyright (C) 2002-2003 Martin Edenhofer <[EMAIL PROTECTED]>
# --
-# $Id: DB.pm,v 1.9 2004/02/13 00:50:36 martin Exp $
+# $Id: DB.pm,v 1.6 2003/04/03 13:14:20 martin Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
@@ -17,7 +17,7 @@
use strict;
use vars qw($VERSION);
-$VERSION = '$Revision: 1.9 $';
+$VERSION = '$Revision: 1.6 $';
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;
# --
@@ -29,103 +29,133 @@
my $Self = {};
bless ($Self, $Type);
+ # --
# check needed objects
- foreach (qw(LogObject ConfigObject DBObject)) {
+ # --
+ foreach ('LogObject', 'ConfigObject', 'DBObject') {
$Self->{$_} = $Param{$_} || die "No $_!";
}
+ $Self->{LogObject}->Log(
+ Priority => 'notice',
+ Message => "Значение $Self->{ConfigObject}",
+ );
+
+ # --
+ # config options
+ # --
+
+ $Self->{ValidID} = $Self->{ConfigObject}->Get('CustomerAuth')->{ValidID}
+ || die "Need CustomerAuth->ValidID in Kernel/Config.pm!";
+ $Self->{UserField} = $Self->{ConfigObject}->Get('CustomerAuth')->{CustomerAuthUserField}
+ || die "Need CustomerAuth->CustomerAuthUserField in Kernel/Config.pm!";
+ $Self->{PwField} = $Self->{ConfigObject}->Get('CustomerAuth')->{CustomerAuthPwField}
+ || die "Need CustomerAuth->CustomerAuthPwField in Kernel/Config.pm!";
+ $Self->{AuthTable} = $Self->{ConfigObject}->Get('CustomerAuth')->{Params}->{Table}
+ || die "Need CustomerAuth->Params->Table in Kernel/Config.pm!";
+ $Self->{CustIDField} = $Self->{ConfigObject}->Get('CustomerAuth')->{CustomerID}
+ || die "Need CustomerAuth->CustomerID in Kernel/Config.pm!";
+ # --
+ # create new db connect if DSN is given
+ # --
+ if ($Self->{ConfigObject}->Get('CustomerAuth')->{Params}->{DSN}) {
+ $Self->{DBObject} = Kernel::System::DB->new(
+ LogObject => $Param{LogObject},
+ ConfigObject => $Param{ConfigObject},
+ DatabaseDSN => $Self->{ConfigObject}->Get('CustomerAuth')->{Params}->{DSN},
+ DatabaseUser => $Self->{ConfigObject}->Get('CustomerAuth')->{Params}->{User},
+ DatabasePw => $Self->{ConfigObject}->Get('CustomerAuth')->{Params}->{Password},
+ ) || die $DBI::errstr;
+ }
+
+ # --
# Debug 0=off 1=on
+ # --
$Self->{Debug} = 0;
+ # --
+ # create check item object
+ # --
+ $Self->{CheckItemObject} = Kernel::System::CheckItem->new(%Param);
return $Self;
}
# --
-sub GetOption {
- my $Self = shift;
- my %Param = @_;
- # check needed stuff
- if (!$Param{What}) {
- $Self->{LogObject}->Log(Priority => 'error', Message => "Need What!");
- return;
- }
- # module options
- my %Option = (
- PreAuth => 0,
- );
- # return option
- return $Option{$Param{What}};
-}
-# --
sub Auth {
my $Self = shift;
my %Param = @_;
+ # --
# check needed stuff
+ # --
if (!$Param{User}) {
$Self->{LogObject}->Log(Priority => 'error', Message => "Need User!");
return;
}
- # db quote
- foreach (keys %Param) {
- $Param{$_} = $Self->{DBObject}->Quote($Param{$_});
- }
+ # --
# get params
+ # --
my $User = $Param{User} || '';
my $Pw = $Param{Pw} || '';
my $RemoteAddr = $ENV{REMOTE_ADDR} || 'Got no REMOTE_ADDR env!';
my $UserID = '';
my $GetPw = '';
+ # --
# sql query
- my $SQL = "SELECT pw, login ".
- " FROM ".
- " customer_user ".
- " WHERE ".
- " valid_id in ( ${\(join ', ', $Self->{DBObject}->GetValidIDs())} ) ".
- " AND ".
- " login = '$User'";
- $Self->{DBObject}->Prepare(SQL => $SQL);
- while (my @Row = $Self->{DBObject}->FetchrowArray()) {
- $GetPw = $Row[0];
- $UserID = $Row[1];
- }
-
- # crypt given pw
- my $CryptedPw = '';
- my $Salt = $GetPw;
- # strip Salt only for (Extended) DES, not for any of Modular crypt's
- if ($Salt !~ /^\$\d\$/) {
- $Salt =~ s/^(..).*/$1/;
- }
- # and do this check only in such case (unfortunately there is a mod_perl2
- # bug on RH8 - check if crypt() is working correctly) :-/
- if (($Salt =~ /^\$\d\$/) || (crypt('root', '[EMAIL PROTECTED]') eq 'roK20XGbWEsSM')) {
- $CryptedPw = crypt($Pw, $Salt);
- }
- else {
- $Self->{LogObject}->Log(
- Priority => 'notice',
- Message => "The crypt() of your mod_perl(2) is not working correctly! Update mod_perl!",
- );
- my $TempSalt = quotemeta($Salt);
- my $TempPw = quotemeta($Pw);
- my $CMD = "perl -e \"print crypt('$TempPw', '$TempSalt');\"";
- open (IO, " $CMD | ") || print STDERR "Can't open $CMD: $!";
- while (<IO>) {
- $CryptedPw .= $_;
- }
- close (IO);
- chomp $CryptedPw;
- }
+ # --
+ my $SQL = "SELECT ".$Self->{PwField}.", ".$Self->{CustIDField}.
+ " FROM ".$Self->{AuthTable}." WHERE ".
+ $Self->{UserField}." = '$User';";
+ $Self->{DBObject}->Prepare(SQL => $SQL);
+ while (my @RowTmp = $Self->{DBObject}->FetchrowArray()) {
+ $GetPw = $RowTmp[0];
+ $UserID = $RowTmp[1];
+ }
+
+ # --
+ # crypt given pw (unfortunately there is a mod_perl2 bug on RH8 - check if
+ # crypt() is working correctly) :-/
+ # --
+
+# This changes has made ecause my database store passwords in unencrypted state
+
+# my $CryptedPw = '';
+# my $Salt = $GetPw;
+# $Salt =~ s/^(..).*/$1/;
+# if (crypt('root', '[EMAIL PROTECTED]') eq 'roK20XGbWEsSM') {
+# $CryptedPw = crypt($Pw, $Salt);
+# }
+# else {
+# $Self->{LogObject}->Log(
+# Priority => 'notice',
+# Message => "The crypt() of your mod_perl(2) is not working correctly! Update mod_perl!",
+# );
+# my $TempSalt = $Salt;
+# $TempSalt =~ s/'/\\'/g;
+# my $TempPw = $Pw;
+# $TempPw =~ s/'/\\'/g;
+# my $CMD = "perl -e \"print crypt('$TempPw', '$TempSalt');\"";
+# open (IO, " $CMD | ") || print STDERR "Can't open $CMD: $!";
+# while (<IO>) {
+# $CryptedPw .= $_;
+# }
+# close (IO);
+# chomp $CryptedPw;
+# }
+ my $CryptedPw = $Pw;
+ # --
# just in case!
+ # --
if ($Self->{Debug} > 0) {
$Self->{LogObject}->Log(
Priority => 'notice',
- Message => "CustomerUser: '$User' tried to login with Pw: '$Pw' ($UserID/$CryptedPw/$GetPw/$Salt/$RemoteAddr)",
+ Message => "CustomerUser: '$User' tried to login with Pw: '$Pw' ($UserID/$CryptedPw/$GetPw/$RemoteAddr)"
);
}
+ # --
# just a note
+ # --
if (!$Pw) {
$Self->{LogObject}->Log(
Priority => 'notice',
@@ -133,15 +163,19 @@
);
return;
}
+ # --
# login note
+ # --
elsif ((($GetPw)&&($User)&&($UserID)) && $CryptedPw eq $GetPw) {
$Self->{LogObject}->Log(
Priority => 'notice',
Message => "CustomerUser: $User logged in (REMOTE_ADDR: $RemoteAddr).",
);
- return $User;
+ return 1;
}
+ # --
# just a note
+ # --
elsif (($UserID) && ($GetPw)) {
$Self->{LogObject}->Log(
Priority => 'notice',
@@ -149,7 +183,9 @@
);
return;
}
+ # --
# just a note
+ # --
else {
$Self->{LogObject}->Log(
Priority => 'notice',
@@ -161,3 +197,4 @@
# --
1;
+
_______________________________________________
OTRS mailing list: dev - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/dev
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/dev