| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Doorman::Scope; |
|
2
|
5
|
|
|
5
|
|
42887
|
use strict; |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
317
|
|
|
3
|
5
|
|
|
5
|
|
1593
|
use Plack::Util::Accessor qw(name root_url); |
|
|
5
|
|
|
|
|
542
|
|
|
|
5
|
|
|
|
|
41
|
|
|
4
|
5
|
|
|
5
|
|
3604
|
use URI; |
|
|
5
|
|
|
|
|
27906
|
|
|
|
5
|
|
|
|
|
643
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
|
7
|
10
|
|
|
10
|
0
|
2206
|
my $class = shift; |
|
8
|
10
|
|
|
|
|
62
|
return bless { root_url => "http://localhost", name => "users", @_ }, $class; |
|
9
|
|
|
|
|
|
|
} |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub scope_url { |
|
12
|
33
|
|
|
33
|
0
|
104
|
$_[0]->root_url . '/' . $_[0]->name; |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub scope_path { |
|
16
|
4
|
|
|
4
|
0
|
22
|
return URI->new($_[0]->scope_url)->path; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
for my $x (qw(in out)) { |
|
20
|
5
|
|
|
5
|
|
31
|
no strict 'refs'; |
|
|
5
|
|
|
|
|
7
|
|
|
|
5
|
|
|
|
|
821
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
*{ __PACKAGE__ . "::sign_${x}_url" } = sub { |
|
23
|
24
|
|
|
24
|
|
2919
|
return $_[0]->scope_url . "/sign_${x}"; |
|
24
|
|
|
|
|
|
|
}; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
*{ __PACKAGE__ . "::sign_${x}_path" } = sub { |
|
27
|
14
|
|
|
14
|
|
11492
|
my $method = "sign_${x}_url"; |
|
28
|
14
|
|
|
|
|
50
|
return URI->new($_[0]->$method)->path; |
|
29
|
|
|
|
|
|
|
}; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Doorman::Scope |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
C objects are responsible to generate URLs and PATHs that are handled |
|
41
|
|
|
|
|
|
|
by Doorman middlewares. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Attributes can be given in the constructor C as a hash: |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $scope = Doorman::Scope->new( name => "members", root_url => "http://example.com" ); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Or set afterwards by using their accessor methods: |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $scope = Doorman::Scope->new; |
|
52
|
|
|
|
|
|
|
$scope->name("members"); |
|
53
|
|
|
|
|
|
|
$scope->root_url("http://example.com"); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=over 4 |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item name |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Default C<"users">. The scope name used to generate PATHs. The "users" scope name |
|
60
|
|
|
|
|
|
|
generates PATHs prefixed "/users". Specifically they are: |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
/users |
|
63
|
|
|
|
|
|
|
/users/sign_in |
|
64
|
|
|
|
|
|
|
/users/sign_out |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Depending on different app requirements, you might sometimes need to |
|
67
|
|
|
|
|
|
|
avoid the use of "/users" PATH. You can change the scope to |
|
68
|
|
|
|
|
|
|
, say, C<"members"> to generate these URLs: |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
/members |
|
71
|
|
|
|
|
|
|
/members/sign_in |
|
72
|
|
|
|
|
|
|
/members/sign_out |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item root_url |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Default "http://localhost". This is the App root url. Many modern web apps |
|
77
|
|
|
|
|
|
|
take just a domain without path part, like C or |
|
78
|
|
|
|
|
|
|
C. Usually you do not need to tweak this value, the middleware |
|
79
|
|
|
|
|
|
|
can guess it from the request environment. However, if your app lives unders some |
|
80
|
|
|
|
|
|
|
given PATH, you may set this to something like C<"http://mydomain.com/myapp>". |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=back |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 METHODS |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=over 4 |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item sign_in_path |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Returns a string of the sign-in path. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item sign_out_path |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Returns a string of the sign-out path. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item sign_in_url |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Returns a string of the full URL to sign in. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item sign_out_url |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns a string of the full URL to sign out. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=back |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |