| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package WebService::Auth0; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 93531 | use Moo; | 
|  | 1 |  |  |  |  | 8886 |  | 
|  | 1 |  |  |  |  | 4 |  | 
| 4 | 1 |  |  | 1 |  | 1130 | use Module::Runtime qw(use_module); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 5 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | our $VERSION = '0.001'; | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | has ua_handler_class => ( | 
| 9 |  |  |  |  |  |  | is=>'ro', | 
| 10 |  |  |  |  |  |  | required=>1, | 
| 11 |  |  |  |  |  |  | default=>'WebService::Auth0::UA::LWP'); | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | has ua_handler_options => ( | 
| 14 |  |  |  |  |  |  | is=>'ro', | 
| 15 |  |  |  |  |  |  | required=>1, | 
| 16 |  |  |  |  |  |  | default=>sub { [] }); | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | has ua => ( | 
| 19 |  |  |  |  |  |  | is=>'ro', | 
| 20 |  |  |  |  |  |  | init_arg=>undef, | 
| 21 |  |  |  |  |  |  | lazy=>1, | 
| 22 |  |  |  |  |  |  | required=>1, | 
| 23 |  |  |  |  |  |  | default=>sub { | 
| 24 |  |  |  |  |  |  | use_module($_[0]->ua_handler_class)->new( | 
| 25 |  |  |  |  |  |  | @{$_[0]->ua_handler_options}); | 
| 26 |  |  |  |  |  |  | }); | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | has domain => ( | 
| 29 |  |  |  |  |  |  | is=>'ro', | 
| 30 |  |  |  |  |  |  | required=>1 ); | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | has client_id => (is=>'ro', predicate=>'has_client_id'); | 
| 33 |  |  |  |  |  |  | has client_secret => (is=>'ro', predicate=>'has_client_secret'); | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | sub auth { | 
| 36 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 37 | 0 | 0 | 0 |  |  |  | my %args = $_[0] ? ((ref($_[0])||'') eq 'HASH' ? %$_[0] : @_) : (); | 
|  |  | 0 |  |  |  |  |  | 
| 38 |  |  |  |  |  |  |  | 
| 39 | 0 |  |  |  |  |  | %args = ( | 
| 40 |  |  |  |  |  |  | ua => $self->ua, | 
| 41 |  |  |  |  |  |  | domain => $self->domain, | 
| 42 |  |  |  |  |  |  | client_id => $self->client_id, | 
| 43 |  |  |  |  |  |  | %args, | 
| 44 |  |  |  |  |  |  | ); | 
| 45 |  |  |  |  |  |  |  | 
| 46 | 0 | 0 |  |  |  |  | $args{client_secret} = $self->client_secret | 
| 47 |  |  |  |  |  |  | if $self->has_client_secret; | 
| 48 |  |  |  |  |  |  |  | 
| 49 | 0 |  |  |  |  |  | return use_module('WebService::Auth0::Authentication') | 
| 50 |  |  |  |  |  |  | ->new(%args); | 
| 51 |  |  |  |  |  |  | } | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | sub management { | 
| 54 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 55 | 0 | 0 | 0 |  |  |  | my %args = $_[0] ? ((ref($_[0])||'') eq 'HASH' ? %$_[0] : @_) : (); | 
|  |  | 0 |  |  |  |  |  | 
| 56 |  |  |  |  |  |  |  | 
| 57 | 0 |  |  |  |  |  | %args = ( | 
| 58 |  |  |  |  |  |  | ua => $self->ua, | 
| 59 |  |  |  |  |  |  | domain => $self->domain, | 
| 60 |  |  |  |  |  |  | %args, | 
| 61 |  |  |  |  |  |  | ); | 
| 62 |  |  |  |  |  |  |  | 
| 63 | 0 | 0 |  |  |  |  | $args{client_secret} = $self->client_secret | 
| 64 |  |  |  |  |  |  | if $self->has_client_secret; | 
| 65 |  |  |  |  |  |  |  | 
| 66 | 0 |  |  |  |  |  | return use_module('WebService::Auth0::Management') | 
| 67 |  |  |  |  |  |  | ->new(%args); | 
| 68 |  |  |  |  |  |  | } | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | 1; | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | =head1 NAME | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | WebService::Auth0 - Access the Auth0 API | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | use WebService::Auth0; | 
| 79 |  |  |  |  |  |  | my $auth0 = WebService::Auth0->new( | 
| 80 |  |  |  |  |  |  | domain => 'my-domain', | 
| 81 |  |  |  |  |  |  | client_id => 'my-client_id', | 
| 82 |  |  |  |  |  |  | client_secret => 'my-client_secrete'); | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | $auth0->... | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | B WARNING!  This is an early release with hardly any tests.  If you use | 
| 89 |  |  |  |  |  |  | this you should be willing / able to help me hack on it as needed.  I currently | 
| 90 |  |  |  |  |  |  | reserve the right to make breaking changes as needed. | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | Prototype for a web service client for L.  This is probably | 
| 93 |  |  |  |  |  |  | going to change a lot as I learn how it actually works.  I wrote this | 
| 94 |  |  |  |  |  |  | primarily as I was doing L | 
| 95 |  |  |  |  |  |  | since it seemed silly to stick web service client stuff directly into | 
| 96 |  |  |  |  |  |  | the Catalyst authorization credential class. | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =head1 ATTRIBUTES | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | This class defines the following attributes | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | =head2 domain | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | =head2 client_id | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | =head2 client_secret | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | Credentials supplied to you from L. | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | =head2 ua_handler_class | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | Defaults to L, a blocking user agent based on L. | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | =head2 ua_handler_options | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | An arrayref of options tht you pass to your L. | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | =head1 METHODS | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | This class defines the following methods: | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | =head2 auth | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | Factory class that returns an instance of L | 
| 125 |  |  |  |  |  |  | using the current settings. | 
| 126 |  |  |  |  |  |  |  | 
| 127 |  |  |  |  |  |  | =head2 management | 
| 128 |  |  |  |  |  |  |  | 
| 129 |  |  |  |  |  |  | Factory class that returns an instance of L | 
| 130 |  |  |  |  |  |  | using the current settings. | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | L. | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | =head1 AUTHOR | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | John Napiorkowski L | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | =head1 COPYRIGHT & LICENSE | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  | Copyright 2017, John Napiorkowski L | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | This library is free software; you can redistribute it and/or modify it under | 
| 145 |  |  |  |  |  |  | the same terms as Perl itself. | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | =cut |