| 1 | package Catalyst::Model::LDAP::FromAuthentication; | ||||||||||
| 2 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use MooseX::Types::LoadableClass qw/ LoadableClass /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use MooseX::Types::Common::String qw/ NonEmptySimpleStr /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use 5.005003; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | our $VERSION = '0.02'; | |||||||||
| 9 | 1 | $VERSION = eval $VERSION; | |||||||||
| 10 | |||||||||||
| 11 | 1 | extends qw/Catalyst::Model/; | |||||||||
| 12 | |||||||||||
| 13 | 1 | with 'Catalyst::Component::InstancePerContext'; | |||||||||
| 14 | |||||||||||
| 15 | |||||||||||
| 16 | 1 | has connection_class => ( | |||||||||
| 17 | isa => LoadableClass, | ||||||||||
| 18 | is => 'ro', | ||||||||||
| 19 | coerce => 1, | ||||||||||
| 20 | default => 'Catalyst::Model::LDAP::Connection', | ||||||||||
| 21 | ); | ||||||||||
| 22 | |||||||||||
| 23 | 1 | has entry_class => ( | |||||||||
| 24 | isa => LoadableClass, | ||||||||||
| 25 | is => 'ro', | ||||||||||
| 26 | coerce => 1, | ||||||||||
| 27 | default => 'Catalyst::Model::LDAP::Entry', | ||||||||||
| 28 | ); | ||||||||||
| 29 | |||||||||||
| 30 | 1 | has base => ( | |||||||||
| 31 | isa => NonEmptySimpleStr, | ||||||||||
| 32 | is => 'ro', | ||||||||||
| 33 | default => 'dc=com', | ||||||||||
| 34 | ); | ||||||||||
| 35 | |||||||||||
| 36 | 0 | ▶ | after COMPONENT => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 37 | 0 | my ($class, $c, @args) = @_; | |||||||||
| 38 | 0 | ▶ | die("Application is not using Catalyst::Plugin::Authentication, $class cannot work.\n") unless $c->can('user'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 1 | }; | |||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | sub build_per_context_instance { | ||||||||
|
Subroutine
build_per_context_instance: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 42 | 0 | my ($self, $c) = @_; | |||||||||
| 43 | 0 | my $user = $c->user; | |||||||||
| 44 | 0 | ▶ | die("No authenticated user") unless $user; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 0 | ▶ | die("User $user does not have an >ldap_connection method") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | unless $user->can('ldap_connection'); | ||||||||||
| 47 | 0 | my $connection = $user->ldap_connection; | |||||||||
| 48 | 0 | my $model = bless $connection, $self->connection_class; | |||||||||
| 49 | 0 | $model->{entry_class} = $self->entry_class; | |||||||||
| 50 | 0 | $model->{base} = $self->base; | |||||||||
| 51 | 0 | return $model; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 55 | |||||||||||
| 56 | =head1 NAME | ||||||||||
| 57 | |||||||||||
| 58 | Catalyst::Model::LDAP::FromAuthentication - Provides an LDAP model bound as the user who logged in. | ||||||||||
| 59 | |||||||||||
| 60 | =head2 SYNOPSIS | ||||||||||
| 61 | |||||||||||
| 62 | package MyApp::Model::LDAP; | ||||||||||
| 63 | use Moose; | ||||||||||
| 64 | use namespace::autoclean; | ||||||||||
| 65 | |||||||||||
| 66 | extends 'Catalyst::Model::LDAP::FromAuthentication'; | ||||||||||
| 67 | |||||||||||
| 68 | # Elsewhere | ||||||||||
| 69 | $c->model('LDAP'); | ||||||||||
| 70 | |||||||||||
| 71 | =head2 DESCRIPTION | ||||||||||
| 72 | |||||||||||
| 73 | This model is a shim used to mash up L<Catalyst::Authentication::Store::LDAP> | ||||||||||
| 74 | and L<Catalyst::Model::LDAP>. | ||||||||||
| 75 | |||||||||||
| 76 | It will return L<Catalyst::Authentication::Store::LDAP> object bound to the | ||||||||||
| 77 | directory as the logged in user. | ||||||||||
| 78 | |||||||||||
| 79 | =head1 AUTHOR | ||||||||||
| 80 | |||||||||||
| 81 | Tomas Doran (t0m) C<< <bobtfish@bobtfish.net >> | ||||||||||
| 82 | |||||||||||
| 83 | =head1 COPYRIGHT | ||||||||||
| 84 | |||||||||||
| 85 | Copyright 2009 state51 | ||||||||||
| 86 | |||||||||||
| 87 | =head1 LICENSE | ||||||||||
| 88 | |||||||||||
| 89 | This program is free software; you can redistribute it and/or modify it under | ||||||||||
| 90 | the same terms as Perl itself. | ||||||||||
| 91 | |||||||||||
| 92 | =cut | ||||||||||
| 93 | |||||||||||