Skip to content

Commit

Permalink
Use source from profile if not defined in module
Browse files Browse the repository at this point in the history
  • Loading branch information
jrouzierinverse committed Dec 18, 2024
1 parent 2acb4bb commit 70ee116
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ Facebook OAuth module
use Moose;
extends 'captiveportal::DynamicRouting::Module::Authentication::OAuth';

has '+source' => (isa => 'pf::Authentication::Source::FacebookSource');
has '+source' => (
isa => 'pf::Authentication::Source::FacebookSource',
lazy => 1,
builder => '_build_source',
);

sub _build_source {
my ($self) = @_;
return $self->app->profile->getSourceByType('Facebook');
}

=head1 AUTHOR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ Github OAuth module
use Moose;
extends 'captiveportal::DynamicRouting::Module::Authentication::OAuth';

has '+source' => (isa => 'pf::Authentication::Source::GithubSource');
has '+source' => (
isa => 'pf::Authentication::Source::GithubSource',
lazy => 1,
builder => '_build_source',
);

has '+token_scheme' => (default => "auth-header:token");

Expand All @@ -28,6 +32,11 @@ sub _extract_username_from_response {
return $info->{email} || $info->{login}.'@github';
}

sub _build_source {
my ($self) = @_;
return $self->app->profile->getSourceByType('Github');
}

=head1 AUTHOR
Inverse inc. <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ Google OAuth module
use Moose;
extends 'captiveportal::DynamicRouting::Module::Authentication::OAuth';

has '+source' => (isa => 'pf::Authentication::Source::GoogleSource');
has '+source' => (
isa => 'pf::Authentication::Source::GoogleSource',
lazy => 1,
builder => '_build_source',
);

sub _build_source {
my ($self) = @_;
return $self->app->profile->getSourceByType('Google');
}

=head1 AUTHOR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ use JSON::MaybeXS;

has '+token_scheme' => (default => 'auth-header:Bearer');

has '+source' => (isa => 'pf::Authentication::Source::LinkedInSource');
has '+source' => (
isa => 'pf::Authentication::Source::LinkedInSource',
lazy => 1,
builder => '_build_source',
);

=head2 _decode_response
Expand All @@ -31,6 +35,11 @@ sub _decode_response {
return {email => $data->{elements}->[0]->{'handle~'}->{emailAddress}};
}

sub _build_source {
my ($self) = @_;
return $self->app->profile->getSourceByType('LinkedIn');
}

=head1 AUTHOR
Inverse inc. <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ use Moose;
use pf::person qw(person_view);
extends 'captiveportal::DynamicRouting::Module::Authentication::OAuth';

has '+source' => (isa => 'pf::Authentication::Source::OpenIDSource');
has '+source' => (
isa => 'pf::Authentication::Source::OpenIDSource',
lazy => 1,
builder => '_build_source',
);

has 'token_scheme' => (is => 'rw', default => sub {"auth-header:Bearer"});

Expand All @@ -41,6 +45,11 @@ sub auth_source_params_child {
return $self->source->map_from_person($info);
}

sub _build_source {
my ($self) = @_;
return $self->app->profile->getSourceByType('OpenID');
}

=head1 AUTHOR
Inverse inc. <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ extends 'captiveportal::DynamicRouting::Module::Authentication::OAuth';

has '+token_scheme' => (default => "auth-header:Bearer");

has '+source' => (isa => 'pf::Authentication::Source::WindowsLiveSource');
has '+source' => (
isa => 'pf::Authentication::Source::WindowsLiveSource',
lazy => 1,
builder => '_build_source',
);

=head2 _extract_username_from_response
Expand All @@ -28,6 +32,11 @@ sub _extract_username_from_response {
return $info->{emails}->{account};
}

sub _build_source {
my ($self) = @_;
return $self->app->profile->getSourceByType('WindowsLive');
}

=head1 AUTHOR
Inverse inc. <[email protected]>
Expand Down

0 comments on commit 70ee116

Please sign in to comment.