line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Darkpan; |
2
|
1
|
|
|
1
|
|
787
|
use v5.20; |
|
1
|
|
|
|
|
4
|
|
3
|
1
|
|
|
1
|
|
577
|
use Data::Dumper; |
|
1
|
|
|
|
|
6902
|
|
|
1
|
|
|
|
|
63
|
|
4
|
1
|
|
|
1
|
|
484
|
use FindBin; |
|
1
|
|
|
|
|
1059
|
|
|
1
|
|
|
|
|
51
|
|
5
|
1
|
|
|
1
|
|
536
|
use Mojo::Base 'Mojolicious', -signatures; |
|
1
|
|
|
|
|
189366
|
|
|
1
|
|
|
|
|
10
|
|
6
|
1
|
|
|
1
|
|
325411
|
use Mojo::Darkpan::Config; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
230
|
|
7
|
|
|
|
|
|
|
|
8
|
0
|
|
|
0
|
1
|
|
sub startup ($self) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# https://metacpan.org/pod/Mojolicious::Plugin::BasicAuthPlus |
11
|
0
|
|
|
|
|
|
$self->plugin('basic_auth_plus'); |
12
|
0
|
|
|
|
|
|
$self->plugin( 'DirectoryHandler', |
13
|
|
|
|
|
|
|
delivery_path => Mojo::Darkpan::Config->new->path ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#---------- |
16
|
|
|
|
|
|
|
# Router |
17
|
|
|
|
|
|
|
#---------- |
18
|
0
|
|
|
|
|
|
my $r = $self->routes; |
19
|
0
|
|
|
|
|
|
my $index = $r->any('/'); |
20
|
0
|
|
|
|
|
|
$index->get('/list')->to( controller => 'index', action => 'list' ); |
21
|
0
|
|
|
|
|
|
$index->get('/reindex')->to( controller => 'index', action => 'reindex' ); |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $uploader = $r->any('/publish'); |
24
|
0
|
|
|
|
|
|
$uploader->post('/')->to( controller => 'publish', action => 'upload' ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# goes to the same place as publish, used for compatibility |
27
|
0
|
|
|
|
|
|
my $authenquery = $r->any('/authenquery'); |
28
|
0
|
|
|
|
|
|
$authenquery->post('/')->to( controller => 'publish', action => 'upload' ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $VERSION = "0.09"; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
__END__ |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=encoding utf-8 |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Mojo::Darkpan - A Mojolicious web service frontend leveraging OrePAN2 |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Mojo::Darkpan is a webservice build on Mojolicious to frontend L<OrePAN2|https://metacpan.org/pod/OrePAN2>. This module was inspired |
46
|
|
|
|
|
|
|
by L<OrePAN2::Server|https://metacpan.org/pod/OrePAN2::Server'> but built on |
47
|
|
|
|
|
|
|
Mojolicious to take advantage of it's robust framework of tools. A good bit of the documentation |
48
|
|
|
|
|
|
|
was also taken from OrePAN2::Server as the functionality is similar if not identical. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SYNOPSIS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 Running the server |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# start a server with default configurations on port 8080 |
55
|
|
|
|
|
|
|
darkpan --port 8080 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# start a server with AD backed basic auth |
58
|
|
|
|
|
|
|
# config.json |
59
|
|
|
|
|
|
|
{ |
60
|
|
|
|
|
|
|
"basic_auth": { |
61
|
|
|
|
|
|
|
"Realm Name": { |
62
|
|
|
|
|
|
|
"host": "ldaps://my.ldap.server.org", |
63
|
|
|
|
|
|
|
"port": 636, |
64
|
|
|
|
|
|
|
"basedn": "DC=my,DC=compoany,DC=org", |
65
|
|
|
|
|
|
|
"binddn": "bind_name", |
66
|
|
|
|
|
|
|
"bindpw": "bond_pw", |
67
|
|
|
|
|
|
|
"filter": "(&(objectCategory=*)(sAMAccountName=%s)(|(objectClass=user)(objectClass=group)))" |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
darkpan --config ./config.json |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head4 Options: |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=over 2 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item B<-c,--config> I<default: undef>: |
79
|
|
|
|
|
|
|
JSON configuration file location |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item B<-p,--port> I<default: 3000>: |
82
|
|
|
|
|
|
|
Web application port |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=back |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head4 Paths: |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=over 2 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item B</publish> or B</authenquery>: |
91
|
|
|
|
|
|
|
POST path(s) for releasing packages, set as the upload_uri in your .pause file |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item B</list>: |
94
|
|
|
|
|
|
|
JSON list of packages and info about them |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item B</reindex>: |
97
|
|
|
|
|
|
|
Force OrePAN2 to do a index all modules and recreate the 02packages.details file. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item B</darkpan> I<(may differ if you set a custom path)>: |
100
|
|
|
|
|
|
|
Directory listing of the repository. This is the path to reference as your mirror or |
101
|
|
|
|
|
|
|
set the PERL_CARTON_MIRROR env var |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=back |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 Configuring the server |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Configurations can be done using environment variables or by creating a json config file. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head3 environment variables |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Environment variables are at a higher order than values set in the json configuration |
112
|
|
|
|
|
|
|
file and will take precedence if set. The B<DARKPAN_CONFIG_FILE> env variable can be |
113
|
|
|
|
|
|
|
set instead of using the command line option to denote the path of the config file. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over 2 |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item B<DARKPAN_CONFIG_FILE>: |
118
|
|
|
|
|
|
|
Location of a json configuration file, same as passing the --config option |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item B<DARKPAN_DIRECTORY>: |
121
|
|
|
|
|
|
|
Directory where uploads will be stored. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item B<DARKPAN_PATH>: |
124
|
|
|
|
|
|
|
URL path to function as cpan repository resolver/mirror endpoint. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item B<DARKPAN_COMPRESS_INDEX>: |
127
|
|
|
|
|
|
|
Setting whether to compress (gzip) the 02packages.details.txt file. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item B<DARKPAN_AUTH_REALM>: |
130
|
|
|
|
|
|
|
Basic auth realm name. This variable needs to be set to enable parsing of additional |
131
|
|
|
|
|
|
|
auth settings using the following the format DARKPAN_AUTH_[setting]. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item B<DARKPAN_AUTH_[setting]>: |
134
|
|
|
|
|
|
|
Additional basic auth settings can be passed using this format. The settings |
135
|
|
|
|
|
|
|
will be parsed and applied to your basic auth configurations. See |
136
|
|
|
|
|
|
|
L<Mojolicious::Plugin::BasicAuthPlus|https://metacpan.org/pod/Mojolicious::Plugin::BasicAuthPlus> |
137
|
|
|
|
|
|
|
for additional details on configurations. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head3 config.json |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
The config.json file contains customizations for the darkpan web application. It can be |
144
|
|
|
|
|
|
|
referenced by absolute path or relative to where the application is run from. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
{ |
147
|
|
|
|
|
|
|
"directory": "darkpan", |
148
|
|
|
|
|
|
|
"compress_index": true, |
149
|
|
|
|
|
|
|
"path": "darkpan", |
150
|
|
|
|
|
|
|
"basic_auth": { |
151
|
|
|
|
|
|
|
"Realm Name": { |
152
|
|
|
|
|
|
|
"host": "ldaps://my.ldap.server.org", |
153
|
|
|
|
|
|
|
"port": 636, |
154
|
|
|
|
|
|
|
"basedn": "DC=my,DC=compoany,DC=org", |
155
|
|
|
|
|
|
|
"binddn": "bind_name", |
156
|
|
|
|
|
|
|
"bindpw": "bond_pw", |
157
|
|
|
|
|
|
|
"filter": "(&(objectCategory=*)(sAMAccountName=%s)(|(objectClass=user)(objectClass=group)))" |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head4 config.json options |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=over 2 |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item B<directory> I<default: darkpan>: |
167
|
|
|
|
|
|
|
Directory where uploads will be stored. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item B<path> I<default: darkpan>: |
170
|
|
|
|
|
|
|
URL path to function as cpan repository resolver/mirror endpoint. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item B<compress_index> I<default: true>: |
173
|
|
|
|
|
|
|
Setting whether to compress (gzip) the 02packages.details.txt file. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item B<basic_auth> I<default: undef>: |
176
|
|
|
|
|
|
|
Basic authentication settings, see configurations for L<Mojolicious::Plugin::BasicAuthPlus|https://metacpan.org/pod/Mojolicious::Plugin::BasicAuthPlus>. When not provided |
177
|
|
|
|
|
|
|
no authentication is necessary to post modules to the service. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=back |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head3 Authentication |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Authentication is handled by L<Mojolicious::Plugin::BasicAuthPlus|https://metacpan.org/pod/Mojolicious::Plugin::BasicAuthPlus>. |
184
|
|
|
|
|
|
|
To configure basic auth, see the configuration options for L<Mojolicious::Plugin::BasicAuthPlus|https://metacpan.org/pod/Mojolicious::Plugin::BasicAuthPlus> |
185
|
|
|
|
|
|
|
and add your settings to the basic auth section of the config.json file. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head2 How to Publish |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head3 Publishing with POST |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Publishing to darkpan can be done using a post request and a URL to git or bitbucket repo. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
#upload git managed module to my darkpan by curl |
194
|
|
|
|
|
|
|
curl --data-urlencode 'module=git+ssh://git@mygit/home/git/repos/MyModule.git' --data-urlencode 'author=reshingleton' http://localhost:3000/publish |
195
|
|
|
|
|
|
|
curl --data-urlencode 'module=git+file:///home/rshingleton/project/MyModule.git' --data-urlencode 'author=reshingleton' http://localhost:3000/publish |
196
|
|
|
|
|
|
|
curl --data-urlencode 'module=git@github.com:rshingleton/perl-module-test.git' --data-urlencode 'author=reshingleton' http://localhost:3000/publish |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Publishing with a local file |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
#upload file from disk via curl |
201
|
|
|
|
|
|
|
curl -F 'pause99_add_uri_httpupload=@filename.tar.gz' http://localhost:3000/publish |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
The module parameter can also be an HTTP url. see L<OrePAN2::Injector|https://metacpan.org/pod/OrePAN2::Injector> for |
205
|
|
|
|
|
|
|
additional details. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
curl --data-urlencode 'module=https://cpan.metacpan.org/authors/id/O/OA/OALDERS/OrePAN2-0.48.tar.gz' --data-urlencode 'author=OALDERS' http://localhost:3000/publish |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head3 Publishing with L<Minilla|https://metacpan.org/pod/Minilla> |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Minilla is a cpan authoring tool, see L<Minilla|https://metacpan.org/pod/Minilla> for more details. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head4 minil.toml |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Add a reference to a pause configruation file in your minil.toml that points to your darkpan instance. |
216
|
|
|
|
|
|
|
The configuration can reference a relative path as follows: |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
[release] |
219
|
|
|
|
|
|
|
pause_config=".pause" |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head4 .pause file |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
The .pause file is a configuration file for uploading modules to CPAN or your own Darkpan Repository. |
224
|
|
|
|
|
|
|
See L<CPAN::Uploader|https://metacpan.org/pod/CPAN::Uploader> for more detail. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
upload_uri http://my-darkpan.server/publish |
227
|
|
|
|
|
|
|
user myUsername |
228
|
|
|
|
|
|
|
password myPassword |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
I<** if you don't set the upload_uri, you will upload to CPAN> |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
If basic auth is enabled, the username and password set in the .pause file will be |
233
|
|
|
|
|
|
|
used as basic auth credentials. |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head2 How to install from your Darkpan |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head3 cpanm |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
See L<cpanm|https://metacpan.org/pod/cpanm> for additional details. |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
# check CPAN and your Darkpan server |
242
|
|
|
|
|
|
|
cpanm --mirror http://my-darkpan.server/darkpan |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
# check for packages from only your Darkpan server |
245
|
|
|
|
|
|
|
cpanm --mirror-only http://my-darkpan.server/darkpan |
246
|
|
|
|
|
|
|
cpanm --from http://my-darkpan.server/darkpan |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head3 cpm |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
See L<cpm|https://metacpan.org/dist/App-cpm/view/script/cpm> for additional details. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
# resolve distribution names from DARKPAN/modules/02packages.details.txt.gz |
253
|
|
|
|
|
|
|
# and fetch distibutions from DARKPAN/authors/id/... |
254
|
|
|
|
|
|
|
> cpm install --resolver 02packages,http://example.com/darkpan Your::Module |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
# use darkpan first, and if it fails, use metadb and normal CPAN |
257
|
|
|
|
|
|
|
> cpm install --resolver 02packages,http://my-darkpan.server/darkpan --resolver metadb Your::Module |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head3 carton |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
See L<carton|https://metacpan.org/pod/Carton> for additional details. |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
# in the cpanfile |
264
|
|
|
|
|
|
|
# local mirror (darkpan) |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
requires 'Plack', '== 0.9981', |
267
|
|
|
|
|
|
|
dist => 'MYCOMPANY/Plack-0.9981-p1.tar.gz', |
268
|
|
|
|
|
|
|
mirror => 'http://my-darkpan.server/darkpan'; |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Carton also uses an (L<undocumented|https://domm.plix.at/perl/2017_07_carton_darkpan.html>) environment variable PERL_CARTON_MIRROR that will enable you |
271
|
|
|
|
|
|
|
to add your Darkpan server to its list of resolvers. Carton will install from |
272
|
|
|
|
|
|
|
your Darkpan and from the default CPAN mirror. |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
PERL_CARTON_MIRROR=http://my-darkpan.server/darkpan carton install |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=head1 SEE ALSO |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
L<OrePAN2|https://metacpan.org/pod/OrePAN2> |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
L<OrePAN2::Server|https://metacpan.org/pod/OrePAN2::Server> |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=head1 LICENSE |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
Copyright (C) rshingleton. |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
288
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=head1 AUTHOR |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
rshingleton E<lt>reshingleton@gmail.comE<gt> |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=cut |