Bugzilla – Attachment 148464 Details for
Bug 33104
Add vendor interfaces
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33104: Encrypt password
Bug-33104-Encrypt-password.patch (text/plain), 5.84 KB, created by
Jonathan Druart
on 2023-03-21 13:12:22 UTC
(
hide
)
Description:
Bug 33104: Encrypt password
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-03-21 13:12:22 UTC
Size:
5.84 KB
patch
obsolete
>From 379351630b29510bd9a95a8d93776489bc4be2b5 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 2 Mar 2023 13:41:16 +0100 >Subject: [PATCH] Bug 33104: Encrypt password > >--- > Koha/Acquisition/Bookseller.pm | 7 ++- > Koha/Acquisition/Bookseller/Interface.pm | 33 ++++++++++++++ > .../prog/en/modules/acqui/supplier.tt | 43 +++++++++++++------ > 3 files changed, 70 insertions(+), 13 deletions(-) > >diff --git a/Koha/Acquisition/Bookseller.pm b/Koha/Acquisition/Bookseller.pm >index a11c7656438..0ce6b9dd956 100644 >--- a/Koha/Acquisition/Bookseller.pm >+++ b/Koha/Acquisition/Bookseller.pm >@@ -122,7 +122,12 @@ sub interfaces { > sub { > $self->interfaces->delete; > for my $interface (@$interfaces) { >- $self->_result->add_to_aqbookseller_interfaces($interface); >+ Koha::Acquisition::Bookseller::Interface->new( >+ { >+ %$interface, >+ vendor_id => $self->id, >+ } >+ )->store; > } > } > ); >diff --git a/Koha/Acquisition/Bookseller/Interface.pm b/Koha/Acquisition/Bookseller/Interface.pm >index b038f539e4e..a7a232f4546 100644 >--- a/Koha/Acquisition/Bookseller/Interface.pm >+++ b/Koha/Acquisition/Bookseller/Interface.pm >@@ -16,6 +16,7 @@ package Koha::Acquisition::Bookseller::Interface; > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >+use Koha::Encryption; > > use base qw( Koha::Object ); > >@@ -29,6 +30,38 @@ Koha::Acquisition::Bookseller::Interface - Koha Bookseller interface Object clas > > =cut > >+=head3 store >+ >+ $self->store; >+ >+Specific store method to encrypt the password. >+ >+=cut >+ >+sub store { >+ my ($self) = @_; >+ >+ if ( $self->password ) { >+ $self->password(Koha::Encryption->new->encrypt_hex($self->password)); >+ } >+ >+ return $self->SUPER::store; >+} >+ >+=head3 plain_text_password >+ >+ my $plain_text_password = $self->plain_text_password; >+ >+Decrypt the password and return its plain text form. >+ >+=cut >+ >+sub plain_text_password { >+ my ($self) = @_; >+ return Koha::Encryption->new->decrypt_hex($self->password) >+ if $self->password; >+} >+ > =head3 _type > > =cut >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >index 5f50130d58a..a9cf47f255b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >@@ -368,18 +368,28 @@ > <div id="supplier-interfaces" class="page-section"> > <h2>Interfaces</h2> > >- [% FOR interface IN vendor.interfaces %] >+ [% FOR i IN vendor.interfaces %] > <fieldset class="rows"> >- <legend>[% interface.name | html %]</legend> >+ <legend>[% i.name | html %]</legend> > <ul> >- <li> >- <li>Type: [% interface.type | html %]</li> >- <li>URI: [% interface.uri | html %]</li> >- <li>Login: [% interface.login | html %]</li> >- <li>Password: [% interface.password | html %]</li> >- <li>Account email: [% interface.account_email | html %]</li> >- <li>Notes : [% interface.notes | html %]</li> >- </li> >+ [% IF i.type %] >+ <li>Type: [% i.type | html %]</li> >+ [% END %] >+ [% IF i.uri %] >+ <li>URI: [% i.uri | html %]</li> >+ [% END %] >+ [% IF i.login %] >+ <li>Login: [% i.login | html %]</li> >+ [% END %] >+ [% IF i.password %] >+ <li>Password: <span class="password"><a href="#" class="show_password" data-plain-text-password="[% i.plain_text_password | html %]">Show</a></span></li> >+ [% END %] >+ [% IF i.account_email %] >+ <li>Account email: [% i.account_email | html %]</li> >+ [% END %] >+ [% IF i.notes %] >+ <li>Notes : [% i.notes | html %]</li> >+ [% END %] > </ul> > </fieldset> > [% END %] >@@ -539,9 +549,14 @@ > } > > [% IF vendor %] >- let interfaces = [% To.json(vendor.interfaces.unblessed) | $raw %]; >+ let interfaces = []; >+ [% FOR i_object IN vendor.interfaces %] >+ [% SET i = i_object.unblessed %] >+ [% SET i.password = i_object.plain_text_password %] >+ interfaces.push([% To.json(i) | $raw %]); >+ [% END %] > [% ELSE %] >- let interfaces = []; >+ let interfaces = []; > [% END %] > function serialize_interface_form(){ > interfaces = []; >@@ -646,6 +661,10 @@ > $(this).next('.contact_claimissues_hidden').val($(this).is(':checked') ? '1' : '0'); > }); > >+ $('body').on('click', '.show_password', null, function(e){ >+ e.preventDefault(); >+ $(this).parent().replaceWith($(this).data('plain-text-password')); >+ }); > refresh_aliases(); > refresh_interfaces(); > >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33104
:
147632
|
147633
|
147634
|
147635
|
147636
|
147637
|
147638
|
147639
|
148459
|
148460
|
148461
|
148462
|
148463
|
148464
|
148465
|
148466
|
148473
|
148474
|
148475
|
148476
|
148477
|
148478
|
148479
|
148480
|
149375
|
149420
|
149421
|
149422
|
149431
|
149492
|
149493
|
149494
|
149495
|
149496
|
149497
|
149498
|
149499
|
149500
|
149501
|
149502
|
149503
|
149631
|
149632