Advertisement
Guest User

Untitled

a guest
Jun 12th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. package Kernel::System::CustomerAuth::SimpleSso;
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. our @ObjectDependencies = (
  7. 'Kernel::Config',
  8. 'Kernel::System::Log',
  9. );
  10.  
  11. sub new {
  12. my ( $Type, %Param ) = @_;
  13.  
  14. # allocate new hash for object
  15. my $Self = {};
  16. bless( $Self, $Type );
  17.  
  18. # Debug 0=off 1=on
  19. $Self->{Debug} = 0;
  20.  
  21. $Self->{Count} = $Param{Count} || '';
  22.  
  23. return $Self;
  24. }
  25.  
  26. sub GetOption {
  27. my ( $Self, %Param ) = @_;
  28.  
  29. # check needed stuff
  30. if ( !$Param{What} ) {
  31. $Kernel::OM->Get('Kernel::System::Log')->Log(
  32. Priority => 'error',
  33. Message => "Need What!"
  34. );
  35. return;
  36. }
  37.  
  38. # module options
  39. my %Option = (
  40. PreAuth => 1,
  41. );
  42.  
  43. # return option
  44. return $Option{ $Param{What} };
  45. }
  46.  
  47. sub Auth {
  48. my ( $Self, %Param ) = @_;
  49.  
  50. my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
  51.  
  52. my $Token = $ParamObject->GetParam( Param => 'RequestedURL' );
  53.  
  54. use Data::Dumper;
  55. $Kernel::OM->Get('Kernel::System::Log')->Log(
  56. Priority => 'error',
  57. Message => 'ENTROU AQUI SimpleSso '.$Token
  58. );
  59.  
  60. # get params
  61. my $User = $ENV{REMOTE_USER} || $ENV{HTTP_REMOTE_USER};
  62. my $RemoteAddr = $ENV{REMOTE_ADDR} || 'Got no REMOTE_ADDR env!';
  63.  
  64. # return on on user
  65. if ( !$User ) {
  66. $Kernel::OM->Get('Kernel::System::Log')->Log(
  67. Priority => 'notice',
  68. Message =>
  69. "User: No \$ENV{REMOTE_USER} or \$ENV{HTTP_REMOTE_USER} !(REMOTE_ADDR: $RemoteAddr).",
  70. );
  71. return;
  72. }
  73.  
  74. # get config object
  75. my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
  76.  
  77. # replace parts of login
  78. my $Replace = $ConfigObject->Get(
  79. 'Customer::AuthModule::HTTPBasicAuth::Replace' . $Self->{Count},
  80. );
  81. if ($Replace) {
  82. $User =~ s/^\Q$Replace\E//;
  83. }
  84.  
  85. # regexp on login
  86. my $ReplaceRegExp = $ConfigObject->Get(
  87. 'Customer::AuthModule::HTTPBasicAuth::ReplaceRegExp' . $Self->{Count},
  88. );
  89. if ($ReplaceRegExp) {
  90. $User =~ s/$ReplaceRegExp/$1/;
  91. }
  92.  
  93. # log
  94. $Kernel::OM->Get('Kernel::System::Log')->Log(
  95. Priority => 'notice',
  96. Message => "User: $User Authentication ok (REMOTE_ADDR: $RemoteAddr).",
  97. );
  98.  
  99. return $User;
  100. }
  101.  
  102. 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement