Commit 37ec0b0f authored by Yadd's avatar Yadd
Browse files

Apache auth (#595)

parent 1ed74737
package Lemonldap::NG::Portal::Auth::Apache;
use strict;
use Mouse;
use Lemonldap::NG::Portal::Main::Constants;
our $VERSION = '0.1';
extends 'Lemonldap::NG::Portal::Auth::Base';
sub init {
1;
}
sub extractFormInfo {
my ( $self, $req ) = @_;
unless ( $req->{user} = $req->{REMOTE_USER} ) {
$self->lmLog( 'Apache is not configured to authenticate users!',
'error' );
return PE_ERROR;
}
# This is needed for Kerberos authentication
$req->{user} =~ s/^(.*)@.*$/$1/g;
PE_OK;
}
sub authenticate {
PE_OK;
}
sub authForce {
PE_OK;
}
sub authLogout {
PE_OK;
}
1;
......@@ -28,18 +28,33 @@ authentication modules.
use strict;
use Mouse;
use Lemonldap::NG::Portal::Main::Constants;
our $VERSION = '0.1';
extends 'Lemonldap::NG::Portal::Auth::Base';
sub extractFormInfo {...}
sub extractFormInfo {
my ( $self, $req ) = @_;
...
}
sub authenticate {...}
sub authenticate {
my ( $self, $req ) = @_;
...
}
sub authForce {...}
sub authForce {
my ( $self, $req ) = @_;
...
}
sub authLogout {...}
sub authLogout {
my ( $self, $req ) = @_;
...
}
1;
=head1 DESCRIPTION
......
use Test::More;
use strict;
require 't/test-lib.pm';
my $res;
init(
{
logLevel => 'debug',
useSafeJail => 1,
authentication => 'Apache',
userDB => 'Null',
}
);
ok( $res = &client->_get( '/', remote_user => 'dwho' ), 'Auth query' );
ok( $res->[0] == 200, 'Response is 200' ) or explain( $res->[0], 200 );
my $cookies = getCookies($res);
ok( $cookies->{lemonldap}, 'Get cookie' )
or explain( $res, 'Set-Cookie: something' );
clean_sessions();
count(3);
done_testing( count() );
......@@ -87,23 +87,26 @@ sub _get {
{
'HTTP_ACCEPT' => $args{accept}
|| 'application/json, text/plain, */*',
'SCRIPT_NAME' => '',
'SERVER_NAME' => 'auth.example.com',
'HTTP_CACHE_CONTROL' => 'max-age=0',
'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
'PATH_INFO' => $path,
'HTTP_CACHE_CONTROL' => 'max-age=0',
( $args{cookie} ? ( 'HTTP_COOKIE' => $args{cookie} ) : () ),
'HTTP_HOST' => 'auth.example.com',
'HTTP_USER_AGENT' =>
'Mozilla/5.0 (VAX-4000; rv:36.0) Gecko/20350101 Firefox',
'PATH_INFO' => $path,
'REMOTE_ADDR' => '127.0.0.1',
(
$args{remote_user}
? ( 'REMOTE_USER' => $args{remote_user} )
: ()
),
'REQUEST_METHOD' => 'GET',
'REQUEST_URI' => $path
. ( $args{query} ? "?$args{query}" : '' ),
'REQUEST_URI' => $path . ( $args{query} ? "?$args{query}" : '' ),
( $args{query} ? ( 'QUERY_STRING' => $args{query} ) : () ),
'SCRIPT_NAME' => '',
'SERVER_NAME' => 'auth.example.com',
'SERVER_PORT' => '8002',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'HTTP_USER_AGENT' =>
'Mozilla/5.0 (VAX-4000; rv:36.0) Gecko/20350101 Firefox',
'REMOTE_ADDR' => '127.0.0.1',
'HTTP_HOST' => 'auth.example.com'
}
);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment