Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Need advice on AD authentication confirguration in Dancer2 app.

by chandantul (Scribe)
on May 11, 2021 at 03:39 UTC ( [id://11132375]=perlquestion: print w/replies, xml ) Need Help??

chandantul has asked for the wisdom of the Perl Monks concerning the following question:

Hello Smart Monks, I will need your help in AD authentication configuration in app.psgi file. I was able to conifugure simple authentication but not able to configure AD authentication. Please check my below code that is not not leeting me start the app.psgi.

# use this block if you don't need middleware, and only have a single +target Dancer app to run here use webapp; use Plack::Builder; use Authen::Simple::ActiveDirectory; my $ad = Authen::Simple::ActiveDirectory->new( host => 'ldaps//ADDEV.dev.abc.com', principal => 'abc.com' ); builder { enable "Auth::Basic", authenticator => $ad; webapp->to_app; }; my($username, $password, $env) = @_; if ( $ad->authenticate( $username, $password ) ) { # successfull authentication } else { die "Wrong ID and Password\n" }

Please check below error and help me to identify the issue if possible

:Simple::ActiveDirectory::authenticate was an 'undef', which is not on +e of the allowed types: scalar at C:/Strawberry/perl/site/lib/Authen/Simple/Adapter.pm line 42, <DAT +A> line 755. Authen::Simple::Adapter::authenticate(undef, undef, undef) cal +led at C:\Users\Documents\Perl\webapp\bin\app.psgi line 26 require C:\Users\Documents\Perl\webapp\bin\app.psgi called at +(eval 6) line 3 eval 'package Plack::Sandbox::C_3a_5cUsers_5c503004671_5cDocum +ents_5cPerl_5cSynchrony_2dPerl_5cwebapp_5cbin_5capp_2epsgi; { my $app = do $_file; if ( !$app && ( my $error = $@ || $! )) { die $error; } $app; } ' called at C:/Strawberry/perl/site/lib/Plack/Util.pm line 120 Plack::Util::_load_sandbox("C:\\Users\\Documents\\Perl\\webapp +\\bin\\a"...) called at C:/Strawberry/perl/site/lib/Plack/Util.pm lin +e 136 Plack::Util::load_psgi("app.psgi") called at C:/Strawberry/per +l/site/lib/Plack/Runner.pm line 181 Plack::Runner::__ANON__() called at C:/Strawberry/perl/site/li +b/Plack/Runner.pm line 24 Plack::Runner::__ANON__() called at C:/Strawberry/perl/site/li +b/Plack/Runner.pm line 24 Plack::Runner::__ANON__() called at C:/Strawberry/perl/site/li +b/Plack/Runner.pm line 24 Plack::Runner::__ANON__() called at C:/Strawberry/perl/site/li +b/Plack/Runner.pm line 24 Plack::Runner::__ANON__() called at C:/Strawberry/perl/site/li +b/Plack/Loader.pm line 55 Plack::Loader::preload_app(Plack::Loader=HASH(0x65aa50), CODE( +0x2ca34c0)) called at C:/Strawberry/perl/site/lib/Plack/Runner.pm lin +e 276 Plack::Runner::run(Plack::Runner=HASH(0x11aa248)) called at C: +\Strawberry\perl\site\bin/plackup line 7

Replies are listed 'Best First'.
Re: Need advice on AD authentication confirguration in Dancer2 app.
by 1nickt (Canon) on May 11, 2021 at 10:46 UTC

    Hi,

    This:

    my($username, $password, $env) = @_; if ( $ad->authenticate( $username, $password ) ) {
    led to this:
    Authen::Simple::Adapter::authenticate(undef, undef, undef) called at C +:\Users\Documents\Perl\webapp\bin\app.psgi

    So what do you think could be wrong? How can you check that you are making the authenticate() call with the right parameters?

    Hope this helps!


    The way forward always starts with a minimal test.

      Hello, I made the authentication works for AD for this Dacer2 app by the below code but i would like to add the logout option post authentication. How i can achive the same> Please advice with code snippet if possible.

      use webapp; use Plack::Builder; use Authen::Simple::ActiveDirectory; use Log::Log4perl; my $ad = Authen::Simple::ActiveDirectory->new( host => 'ldap://addev.dev.abc.com', principal => 'addev.dev.abc.com', timeout => '60', log => Log::Log4perl->get_logger('Authen::Simple::ActiveDirectory' +) ); builder { enable "Auth::Basic", authenticator => $ad; my ( $username, $password ) = @_; webapp->to_app; };

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11132375]
Approved by Discipulus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (1)
As of 2024-04-24 14:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found