[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-309-g8561063
? sunnavy
sunnavy at bestpractical.com
Fri Aug 13 04:54:18 EDT 2010
The branch, 3.9-trunk has been updated
via 85610635e75920407250d8c9b307e944b5f3f562 (commit)
from 689d244fd5b62b6d64052b3be0f1d1ca9302998a (commit)
Summary of changes:
lib/RT/Config.pm | 24 ++++++++++++++++++++++++
share/html/Admin/Tools/Configuration.html | 21 +--------------------
2 files changed, 25 insertions(+), 20 deletions(-)
- Log -----------------------------------------------------------------
commit 85610635e75920407250d8c9b307e944b5f3f562
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Aug 13 16:27:37 2010 +0800
add callback in Config to obfuscate variable
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 5f1f603..84f3b9c 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -126,6 +126,9 @@ can be set for each config optin:
(such as seeing if a library is installed) and then change
the setting of this or other options in the Config using
the RT::Config option.
+ Obfuscate - subref passed the RT::Config object, current setting of the config option
+ and a user object, can return obfuscated value. it's called in
+ RT->Config->GetObfuscated()
=cut
@@ -737,6 +740,27 @@ sub Get {
return $self->_ReturnValue( $res, $META{$name}->{'Type'} || 'SCALAR' );
}
+=head2 GetObfuscated
+
+the same as Get, except it returns Obfuscated value via Obfuscate sub
+
+=cut
+
+sub GetObfuscated {
+ my $self = shift;
+ my ( $name, $user ) = @_;
+ my $obfuscate = $META{$name}->{Obfuscate};
+
+ # we use two Get here is to simplify the logic of the return value
+ # configs need obfuscation are supposed to be less, so won't be too heavy
+
+ return $self->Get(@_) unless $obfuscate;
+
+ my $res = $self->Get(@_);
+ $res = $obfuscate->( $self, $res, $user );
+ return $self->_ReturnValue( $res, $META{$name}->{'Type'} || 'SCALAR' );
+}
+
=head2 Set
Set option's value to new value. Takes name of the option and new value.
diff --git a/share/html/Admin/Tools/Configuration.html b/share/html/Admin/Tools/Configuration.html
index df1ac8a..ec5e241 100644
--- a/share/html/Admin/Tools/Configuration.html
+++ b/share/html/Admin/Tools/Configuration.html
@@ -68,7 +68,7 @@ unless ($session{'CurrentUser'}->HasRight( Object=> $RT::System, Right => 'Super
<%PERL>
my $index_conf;
foreach my $key ( RT->Config->Options( Overridable => undef, Sorted => 0 ) ) {
- my $val = RT->Config->Get( $key );
+ my $val = RT->Config->GetObfuscated( $key );
next unless defined $val;
my $meta = RT->Config->Meta( $key );
@@ -240,27 +240,8 @@ use Data::Dumper;
local $Data::Dumper::Terse = 1;
local $Data::Dumper::Indent = 2;
-sub obfuscate_password {
- my $value = shift;
- if ( ref $value && ref $value eq 'HASH' ) {
- for my $key ( keys %$value ) {
- if ( $key =~ /password/i ) {
- $value->{$key} = loc('Password not printed'),
- }
- elsif ( ref $value->{$key} && ref $value->{$key} eq 'HASH' ) {
- $value->{$key} = obfuscate_password( $value->{$key} );
- }
- }
- }
- return $value;
-}
-
sub stringify {
my $value = shift;
- if ( ref $value && ref $value eq 'HASH' ) {
- $value = obfuscate_password( $value );
- }
-
my $output = Dumper $value;
RT::Interface::Web::EscapeUTF8(\$output);
$output =~ s/ / /g;
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list