Thread CAP::Dispatch + Authentication Problemde: bei Vererbung (2 answers)
Opened by pktm at 2007-02-02 01:31

pktm
 2007-02-02 01:31
#9564 #9564
User since
2003-08-07
2921 Artikel
BenutzerIn
[Homepage]
user image
Hallo!

Ich habe ein Problem mit CGI::Application::Dispatch und CGI::Application::Plugin::Authentication.

Wenn ich zu meinem CGI::Application-basierte Modul eine Subklasse erstelle habe ich Probleme in dieser Subklasse mit CGI::Application::Plugin::Authentication zu hantieren.

Das Problem ist, dass ich mit Vanilla.cgi arbeite, meine Scripten also so aufrufe: test.cgi/Modul_Subklasse/runmode

Wenn ich jetzt meine Subklasse schützen möchte (und später auch mit Athorisation arbeiten möchte) und dazu das Modul CGI::Application::Plugin::Authentication heranziehe habe ich das Problem, dass ich zwar das Formular zur Eingabe des Benutzernamens und des Passwortes angezeigt bekomme, aber nach erfolgreichem Login nicht auf die Seite gelange, die ich eigentlich angefordert hatte.
CGI::Application::Plugin::Authentication speichert den ursprünglichen Aufruf (mit PATH_INFO) in einem versteckten FOrmularfeld des Login-Formulars und leitet danach darauf um. Nur leider geht dabei scheinbar die PATH_INFO verloren. So lande ich immer bei meinem Erstaufruf (test.cgi), aber nie bei der Seite, wo ich eigentlich hin wollte.
Ich kann auch in POST_LOGIN_RUNMODE oder POST_LOGIN_URL schreiben was ich will, da passiert nichts.

Hat da jemand eine Idee?
Man kann das recht leicht reproduzieren, indem man sich einfach ein entsprechendes Instanz-Skriot anlegt und dann eine SUbklasse dazu und diese mit CGI::Application::Plugin::Authentication schützt.

HIer mal ein bischen Code:
- Oberklasse: hier habe ich überprüft, ob die Athentifizierung auf der Ebene der Oberklasse (nennt man das so?) funktioniert, was es auch tut.
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package My::MyApp;

use strict;
use warnings;
use base 'CGI::Application';
use CGI::Application::Plugin::Session;
use CGI::Application::Plugin::Authentication;
use CGI::Application::Plugin::Redirect;
use CGI::Application::Plugin::Forward;
use CGI::Application::Plugin::DebugScreen;
use CGI::Application::Plugin::ValidateRM;
use CGI::Application::Plugin::ConfigAuto qw/cfg/;
use CGI::Application::Plugin::HtmlTidy;
use Data::Dumper qw/Dumper/;
$Data::Dumper::Sortkeys = 1;

sub setup {
   my $self = shift;
   $self->start_mode('mode1');
   $self->mode_param('rm');
   $self->run_modes(
           'mode1' => 'do_stuff',
           'protected' => 'geschuetzt',
   );

   $self->param('CMS' => $self->query->url(-full=>1,));

} # /setup

sub cgiapp_init {
   my $self = shift;

   # Set some defaults for DFV unless they already exist.  
   $self->param('dfv_defaults') ||
       $self->param('dfv_defaults', {
               missing_optional_valid => 1,
               filters => 'trim',
               msgs => {
                   any_errors => 'FehlerLoop',
                   prefix     => 'Error_',
                   invalid    => 'Ungültig',
                   missing    => 'Fehlend:',
                   format => '<span class="dfv-errors">%s</span>',
               },
           });

   $self->param('Grafik' => $self->cfg('Grafik'));  

   #$self->authen->config(
   #      DRIVER => [ 'Generic', { user1 => '123' } ],
   #);
   #$self->authen->protected_runmodes('protected');
   ##$self->authen->protected_runmodes(':all');

} # /cgiapp_init

sub do_stuff {
   my $self = shift;
   my $url = $self->param('CMS') . '/MyApp/protected';
   
   my $ausg = qq~
   <a href="$url">Linmk zu geschütztem Bereich</a>
   ~;

   return $ausg;
} # /do_stuff

sub geschuetzt {
   my $self = shift;
   
   my $ausg = qq~
   Willkommen im speziell geschützten Bereich.
   ~;
   
   return $ausg;
} # /geschuetzt

sub cgiapp_postrun {
   my $self = shift;
   my $output_ref = shift;
   
   # Sete den Rahmen um den Inhalt, der in den verschiedenen Runmodes erstellt wurde.
   
   my $t = $self->load_tmpl('_hauptTemplate.tmpl', associate => $self);
   $t->param('Seiteninhalt' => $$output_ref);
   $$output_ref = $t->output();
   
   $self->htmltidy_clean($output_ref);
   
} # /cgiapp_postrun

1;


- Unterklasse: hier funktioniert etwas nicht. PATH_INFO wird nicht ausgewertet.
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package My::MyApp::Admin;

use base 'CGI::Application';
use CGI::Application::Plugin::ConfigAuto qw/cfg/;
use CGI::Application::Plugin::DBH (qw/dbh_config dbh/);
use CGI::Application::Plugin::Authentication;
use CGI::Application::Plugin::HtmlTidy;

sub cgiapp_init {
   my $self = shift;
   
   My::MyApp::Admin::->authen->config(
         DRIVER => [ 'Generic', { user1 => '123' } ],
   );
   
   #$self->authen->protected_runmodes(':all');
   My::MyApp::Admin::authen->protected_runmodes(':all');

} # /cgiapp_init


sub setup {
   my $self = shift;
   
   $self->start_mode('start');
   $self->run_modes(
                    start => 'aufgabenbereich',
                    authentifikationsFormular => 'authentifikationsFormular',
                    logout => 'logout',
                   );
   
} # /setup

sub aufgabenbereich {
   my $self = shift;
   
   
   
   return "Mein Aufgabenbereich";
} # /authen_mode

sub authentifikationsFormular {
   my $self = shift;
   
   my $t = $self->load_tmpl('_admin_loginFormular.tmpl');
   $t->param("CMS" => $self->query->url(-full => 1,));
   return $t->output();
   
   return "Formular zum einloggen";
} # /authentifikationsFormular

sub logout {
   my $self = shift;
   
   return "logout formular";
} # /logout

sub cgiapp_postrun {
   my $self = shift;
   my $output_ref = shift;
   
   # Sete den Rahmen um den Inhalt, der in den verschiedenen Runmodes erstellt wurde.
   
   my $t = $self->load_tmpl('_admin_hauptTemplate.tmpl', associate => $self);
   $t->param('Seiteninhalt' => $$output_ref);
   $$output_ref = $t->output();
   
   $self->htmltidy_clean($output_ref);
   
} # /cgiapp_postrun

1;


- Instanz: mit Dispatch-Tabelle und dergleichen.
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/Perl/bin/perl

use strict;
use warnings;
use FindBin qw($Bin);
use CGI::Carp qw/ fatalsToBrowser warningsToBrowser /;
use Data::Dumper qw/Dumper/;
use CGI::Application::Dispatch;
$Data::Dumper::Sortkeys = 1;

$ENV{CGI_APP_DEBUG} = 1;

CGI::Application::Dispatch->dispatch(
   prefix  => 'My',
   default => 'MyApp',
   args_to_new => {
              TMPL_PATH => 'Templates/',
              PARAMS => {
                         cfg_file => $Bin . '/Konfiguration/dispatchtest.pl',
                         htmltidy_config => { config_file => $Bin . '/Konfiguration/tidy.conf', },
                        },
             },
);


Hatte eventuell *zufällig* jemand hier schonmal dieses Problem? Werde mir im Laufe des Tages mal das Auth-Modul von innen ansehen, aber das wird schon einige Zeit in Anspruch nehmen. Vielleicht hat ja bis dahin jemand eine Out-of-the-Box-Lösung für mich :D

Mal sehen.
Grüße, pktm
http://www.intergastro-service.de (mein erstes CMS :) )

View full thread CAP::Dispatch + Authentication Problemde: bei Vererbung