Unificare users di Joomla e OTRS

Post Reply
sushisan
Znuny newbie
Posts: 21
Joined: 09 Jul 2010, 17:31
Znuny Version: 2.4

Unificare users di Joomla e OTRS

Post by sushisan »

Sto cercando di unificare gli usuari de Joomla e OTRS.

Joomla codifica i pass in jos_users nella forma:

"md5(newpassword+salt):salt"

dove salt sono 32 caratteri alleatori.

Ho provato questo: http://www.mail-archive.com/otrs@otrs.org/msg29104.html
e rieco a codificare i pass in MD5.

Come faccio ad aggiungere il SALT??

Grazie!
sushisan
Znuny newbie
Posts: 21
Joined: 09 Jul 2010, 17:31
Znuny Version: 2.4

Re: Unificare users di Joomla e OTRS

Post by sushisan »

Un'altra domanda:

Come posso unificare le sessioni di Joomla e OTRS?
sushisan
Znuny newbie
Posts: 21
Joined: 09 Jul 2010, 17:31
Znuny Version: 2.4

Re: Unificare users di Joomla e OTRS

Post by sushisan »

questo codice genera una passw come Joomla:

use Digest::MD5 qw(md5_hex);
my $salt = md5_hex(rand());
$crypted = " md5(".md5_hex($pass.$salt).":".$salt.")";
sushisan
Znuny newbie
Posts: 21
Joined: 09 Jul 2010, 17:31
Znuny Version: 2.4

Re: Unificare users di Joomla e OTRS

Post by sushisan »

QUESTO FUNZIONA!!!!:

-------------------------
diff /opt/otrs/Kernel/System/CustomerAuth/DB.pm.orig /opt/otrs/Kernel/System/CustomerAuth/DB.pm
------

16c16
<
---
> use Digest::MD5 qw(md5_hex);
135d134
<
137,138c136,137
< $Salt =~ s/^\$.+?\$(.+?)\$.*$/$1/;
<
---
> #$Salt =~ s/^\$.+?\$(.+?)\$.*$/$1/;
> $Salt =~ s/^.*:/$1/;
143c142,143
< $CryptedPw = unix_md5_crypt( $Pw, $Salt );
---
> #$CryptedPw = unix_md5_crypt( $Pw, $Salt );
> $CryptedPw = md5_hex($Pw.$Salt).":".$Salt;
151,153c151,153
< if ( $Salt !~ /^\$\d\$/ ) {
< $Salt =~ s/^(..).*/$1/;
< }
---
> #if ( $Salt !~ /^\$\d\$/ ) {
> # $Salt =~ s/^(..).*/$1/;
> #}
157,159c157,159
< if ( $Salt =~ /^\$\d\$/ || ( crypt( 'root', 'root@localhost' ) eq 'roK20XGbWEsSM' ) ) {
< $Self->{EncodeObject}->EncodeOutput( \$Pw );
< $Self->{EncodeObject}->EncodeOutput( \$Salt );
---
> #if ( $Salt =~ /^\$\d\$/ || ( crypt( 'root', 'root@localhost' ) eq 'roK20XGbWEsSM' ) ) {
> # $Self->{EncodeObject}->EncodeOutput( \$Pw );
> # $Self->{EncodeObject}->EncodeOutput( \$Salt );
162,165c162,165
< $CryptedPw = crypt( $Pw, $Salt );
< $Self->{EncodeObject}->Encode( \$CryptedPw );
< }
< else {
---
> # $CryptedPw = crypt( $Pw, $Salt );
> # $Self->{EncodeObject}->Encode( \$CryptedPw );
> #}
> #else {
180c180
< }
---
> #}
-------------------------------------------------
diff /opt/otrs/Kernel/System/CustomerUser/DB.pm.orig /opt/otrs/Kernel/System/CustomerUser/DB.pm
----------

16c16
<
---
> use Digest::MD5 qw(md5_hex);
789c789
<
---
> my $Salt = md5_hex(rand());
792,794c792,795
< $Self->{EncodeObject}->EncodeOutput( \$Login );
<
< $CryptedPw = unix_md5_crypt( $Pw, $Login );
---
> #$Self->{EncodeObject}->EncodeOutput( \$Login );
> $Self->{EncodeObject}->EncodeOutput( \$Salt );
> #$CryptedPw = unix_md5_crypt( $Pw, $Login );
> $CryptedPw = md5_hex($Pw.$Salt).":".$Salt;

---------------------------------------
La base di dati ha bisogno di 65bytes in passwd

diff /opt/otrs/scripts/database/otrs-schema.mysql.sql.orig /opt/otrs/scripts/database/otrs-schema.mysql.sql
--------

65c65
< pw VARCHAR (50) NOT NULL,
---
> pw VARCHAR (65) NOT NULL,
911c911
< pw VARCHAR (50) NULL,
---
> pw VARCHAR (65) NULL,
sushisan
Znuny newbie
Posts: 21
Joined: 09 Jul 2010, 17:31
Znuny Version: 2.4

Re: Unificare users di Joomla e OTRS

Post by sushisan »

Con context diff:
---------------------------------------------------
---------------------------------------------------------------
diff -c /opt/otrs/Kernel/System/CustomerAuth/DB.pm.orig /opt/otrs/Kernel/System/CustomerAuth/DB.pm
----------------------------------------------------------------

*** /opt/otrs/Kernel/System/CustomerAuth/DB.pm.orig 2010-07-09 22:46:03.775934414 -0300
--- /opt/otrs/Kernel/System/CustomerAuth/DB.pm 2010-07-10 12:20:26.468579343 -0300
***************
*** 13,19 ****

use strict;
use warnings;
!
use Crypt::PasswdMD5 qw(unix_md5_crypt);

use vars qw($VERSION);
--- 13,19 ----

use strict;
use warnings;
! use Digest::MD5 qw(md5_hex);
use Crypt::PasswdMD5 qw(unix_md5_crypt);

use vars qw($VERSION);
***************
*** 132,146 ****
$CryptedPw = $Pw;
}
elsif ( $GetPw !~ /^.{13}$/ ) {
-
# strip salt
! $Salt =~ s/^\$.+?\$(.+?)\$.*$/$1/;
!
# encode output, needed by unix_md5_crypt() only non utf8 signs
$Self->{EncodeObject}->EncodeOutput( \$Pw );
$Self->{EncodeObject}->EncodeOutput( \$Salt );

! $CryptedPw = unix_md5_crypt( $Pw, $Salt );
$Self->{EncodeObject}->Encode( \$CryptedPw );
}

--- 132,146 ----
$CryptedPw = $Pw;
}
elsif ( $GetPw !~ /^.{13}$/ ) {
# strip salt
! #$Salt =~ s/^\$.+?\$(.+?)\$.*$/$1/;
! $Salt =~ s/^.*:/$1/;
# encode output, needed by unix_md5_crypt() only non utf8 signs
$Self->{EncodeObject}->EncodeOutput( \$Pw );
$Self->{EncodeObject}->EncodeOutput( \$Salt );

! #$CryptedPw = unix_md5_crypt( $Pw, $Salt );
! $CryptedPw = md5_hex($Pw.$Salt).":".$Salt;
$Self->{EncodeObject}->Encode( \$CryptedPw );
}

***************
*** 148,168 ****
else {

# 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', 'root@localhost' ) eq 'roK20XGbWEsSM' ) ) {
! $Self->{EncodeObject}->EncodeOutput( \$Pw );
! $Self->{EncodeObject}->EncodeOutput( \$Salt );

# encode output, needed by crypt() only non utf8 signs
! $CryptedPw = crypt( $Pw, $Salt );
! $Self->{EncodeObject}->Encode( \$CryptedPw );
! }
! else {
$Self->{LogObject}->Log(
Priority => 'notice',
Message =>
--- 148,168 ----
else {

# 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', 'root@localhost' ) eq 'roK20XGbWEsSM' ) ) {
! # $Self->{EncodeObject}->EncodeOutput( \$Pw );
! # $Self->{EncodeObject}->EncodeOutput( \$Salt );

# encode output, needed by crypt() only non utf8 signs
! # $CryptedPw = crypt( $Pw, $Salt );
! # $Self->{EncodeObject}->Encode( \$CryptedPw );
! #}
! #else {
$Self->{LogObject}->Log(
Priority => 'notice',
Message =>
***************
*** 177,183 ****
}
close(IO);
chomp $CryptedPw;
! }
}

# just in case!
--- 177,183 ----
}
close(IO);
chomp $CryptedPw;
! #}
}

# just in case!

-------------------------------------------------------------------------------------------
diff -c /opt/otrs/Kernel/System/CustomerUser/DB.pm.orig /opt/otrs/Kernel/System/CustomerUser/DB.pm
-----------------------------------------------

*** /opt/otrs/Kernel/System/CustomerUser/DB.pm.orig 2010-07-09 22:53:15.815936292 -0300
--- /opt/otrs/Kernel/System/CustomerUser/DB.pm 2010-07-10 12:20:48.126330149 -0300
***************
*** 13,19 ****

use strict;
use warnings;
!
use Crypt::PasswdMD5 qw(unix_md5_crypt);

use Kernel::System::CheckItem;
--- 13,19 ----

use strict;
use warnings;
! use Digest::MD5 qw(md5_hex);
use Crypt::PasswdMD5 qw(unix_md5_crypt);

use Kernel::System::CheckItem;
***************
*** 786,797 ****

# crypt with md5 crypt
else {
!
# encode output, needed by unix_md5_crypt() only non utf8 signs
$Self->{EncodeObject}->EncodeOutput( \$Pw );
! $Self->{EncodeObject}->EncodeOutput( \$Login );
!
! $CryptedPw = unix_md5_crypt( $Pw, $Login );
$Self->{EncodeObject}->Encode( \$CryptedPw );
}

--- 786,798 ----

# crypt with md5 crypt
else {
! my $Salt = md5_hex(rand());
# encode output, needed by unix_md5_crypt() only non utf8 signs
$Self->{EncodeObject}->EncodeOutput( \$Pw );
! #$Self->{EncodeObject}->EncodeOutput( \$Login );
! $Self->{EncodeObject}->EncodeOutput( \$Salt );
! #$CryptedPw = unix_md5_crypt( $Pw, $Login );
! $CryptedPw = md5_hex($Pw.$Salt).":".$Salt;
$Self->{EncodeObject}->Encode( \$CryptedPw );
}

-------------------------------------------------------------------------------
diff -c /opt/otrs/scripts/database/otrs-schema.mysql.sql.orig /opt/otrs/scripts/database/otrs-schema.mysql.sql
-------------------------------------------------------

*** /opt/otrs/scripts/database/otrs-schema.mysql.sql.orig 2010-02-05 20:42:17.000000000 -0300
--- /opt/otrs/scripts/database/otrs-schema.mysql.sql 2010-07-10 12:44:07.190580174 -0300
***************
*** 62,68 ****
CREATE TABLE users (
id INTEGER NOT NULL AUTO_INCREMENT,
login VARCHAR (100) NOT NULL,
! pw VARCHAR (50) NOT NULL,
salutation VARCHAR (50) NULL,
first_name VARCHAR (100) NOT NULL,
last_name VARCHAR (100) NOT NULL,
--- 62,68 ----
CREATE TABLE users (
id INTEGER NOT NULL AUTO_INCREMENT,
login VARCHAR (100) NOT NULL,
! pw VARCHAR (65) NOT NULL,
salutation VARCHAR (50) NULL,
first_name VARCHAR (100) NOT NULL,
last_name VARCHAR (100) NOT NULL,
***************
*** 908,914 ****
login VARCHAR (100) NOT NULL,
email VARCHAR (150) NOT NULL,
customer_id VARCHAR (200) NOT NULL,
! pw VARCHAR (50) NULL,
salutation VARCHAR (50) NULL,
first_name VARCHAR (100) NOT NULL,
last_name VARCHAR (100) NOT NULL,
--- 908,914 ----
login VARCHAR (100) NOT NULL,
email VARCHAR (150) NOT NULL,
customer_id VARCHAR (200) NOT NULL,
! pw VARCHAR (65) NULL,
salutation VARCHAR (50) NULL,
first_name VARCHAR (100) NOT NULL,
last_name VARCHAR (100) NOT NULL,
diagobd2
Znuny newbie
Posts: 3
Joined: 27 Apr 2013, 12:20
Znuny Version: dfgfg
Real Name: jacob
Company: xy-business

Re: Unificare users di Joomla e OTRS

Post by diagobd2 »

use warnings;
! use Digest::MD5 qw(md5_hex);
use Crypt::PasswdMD5 qw(unix_md5_crypt)








___________________________________
SBB Key Programmervas 5054a
Post Reply