Commits

Toby Inkster  committed b312111

split from p5-web-id

  • Participants

Comments (0)

Files changed (10)

+use inc::Module::Package 'RDF:standard';
+

File lib/Plack/Middleware/Apache2/ModSSL.pm

+package Plack::Middleware::Apache2::ModSSL;
+
+use strict;
+use base qw(Plack::Middleware);
+use Apache2::ModSSL;
+use Plack::Util::Accessor qw(vars client_exts server_exts);
+
+sub call
+{
+	my ($self, $env) = @_;
+	my $c = $env->{'psgi.input'}->connection;
+	
+	$env->{$_} //= $c->ssl_var_lookup($_)
+		for @{ $self->vars // [] };
+	
+	$env->{"SERVER:$_"} //= $c->ssl_ext_lookup(0, $_)
+		for @{ $self->server_exts // [] };
+	
+	$env->{"CLIENT:$_"} //= $c->ssl_ext_lookup(1, $_)
+		for @{ $self->client_exts // [] };
+	
+	$self->app->($env);
+}
+
+__PACKAGE__
+__END__
+
+=head1 NAME
+
+Plack::Middleware::Apache2::ModSSL - pull in $env data from mod_ssl API
+
+=head1 SYNOPSIS
+
+ builder
+ {
+   enable "Apache2::ModSSL",
+          vars => [qw(SSL_CLIENT_CERT)];
+   $app;
+ };
+
+=head1 DESCRIPTION
+
+Apache mod_ssl provides a bunch of data about the SSL connection. While
+much of this is often exposed in environment variables, sometimes server
+configuration (especially the I<SSLOptions> configuration directive)
+will result in some of the data not being available to your application.
+This module pokes into the mod_ssl API to retrieve the data you need and
+stash it away in Plack's C<< $env >>.
+
+You may be able to tweak your Apache configuration and persuade it to
+give you the data you want via environment variables, in which case
+Plack's Apache2 handler will automatically copy them into C<< $env >>
+and you don't need this module.
+
+=head2 C<vars>
+
+Specifies an arrayref listing SSL-related variables to add to C<< $env >>.
+
+=head2 C<server_exts>
+
+An arrayref of OIDs which will be exported from the server's certificate.
+It's incredibly unlikely you need this.
+
+=head2 C<client_exts>
+
+An arrayref of OIDs which will be exported from the client's certificate.
+It's pretty unlikely you need this.
+
+=head1 BUGS
+
+Plack::Middleware::Apache2::ModSSL uses L<Apache2::ModSSL> which is an
+XS module (and a bit of a pain to build at that). The latter has an
+oddity in how it loads up the XS part of the module. To counteract the
+oddity, I've found it necessary to add this to my PSGI, near the top:
+
+ BEGIN { $ENV{MOD_PERL} ||= 'mod_perl' };
+
+If you get error messages about the C<ssl_var_lookup> method not being
+defined in package Apache2::Connection, then try the above.
+
+Please report any other bugs to
+L<http://rt.cpan.org/Dist/Display.html?Queue=Plack-Middleware-Apache2-ModSSL>.
+
+=head1 SEE ALSO
+
+L<Plack>,
+L<Apache2::ModSSL>.
+
+L<http://httpd.apache.org/docs/2.0/mod/mod_ssl.html>.
+
+=head1 AUTHOR
+
+Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
+
+=head1 COPYRIGHT AND LICENCE
+
+This software is copyright (c) 2012 by Toby Inkster.
+
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
+
+=head1 DISCLAIMER OF WARRANTIES
+
+THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

File meta/changes.ttl

+# This file acts as the project's changelog.
+
+@prefix :        <http://usefulinc.com/ns/doap#> .
+@prefix dcs:     <http://ontologi.es/doap-changeset#> .
+@prefix dc:      <http://purl.org/dc/terms/> .
+@prefix dist:    <http://purl.org/NET/cpan-uri/dist/Plack-Middleware-Apache2-ModSSL/> .
+@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
+
+dist:project :release dist:v_0-001 .
+dist:v_0-001
+	a               :Version ;
+	dc:issued       "2012-05-02"^^xsd:date ;
+	:revision       "0.001"^^xsd:string ;
+	:file-release   <http://backpan.cpan.org/authors/id/T/TO/TOBYINK/Plack-Middleware-Apache2-ModSSL-0.001.tar.gz> ;
+	rdfs:label      "Initial release" .
+

File meta/doap.ttl

+# This file contains general metadata about the project.
+
+@prefix :        <http://usefulinc.com/ns/doap#> .
+@prefix dc:      <http://purl.org/dc/terms/> .
+@prefix foaf:    <http://xmlns.com/foaf/0.1/> .
+@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
+
+<http://purl.org/NET/cpan-uri/dist/Plack-Middleware-Apache2-ModSSL/project>
+	a               :Project ;
+	:programming-language "Perl" ;
+	:name           "Plack-Middleware-Apache2-ModSSL" ;
+	:shortdesc      "a module that does something-or-other" ;
+	:homepage       <https://metacpan.org/release/Plack-Middleware-Apache2-ModSSL> ;
+	:download-page  <https://metacpan.org/release/Plack-Middleware-Apache2-ModSSL> ;
+	:bug-database   <http://rt.cpan.org/Dist/Display.html?Queue=Plack-Middleware-Apache2-ModSSL> ;
+	:created        "2012-05-02"^^xsd:date ;
+	:license        <http://dev.perl.org/licenses/> ;
+	:developer      [ a foaf:Person ; foaf:name "Toby Inkster" ; foaf:mbox <mailto:tobyink@cpan.org> ] .
+
+<http://dev.perl.org/licenses/>
+	dc:title        "the same terms as the perl 5 programming language system itself" .
+

File meta/makefile.ttl

+# This file provides instructions for packaging.
+
+@prefix : <http://purl.org/NET/cpan-uri/terms#> .
+
+<http://purl.org/NET/cpan-uri/dist/Plack-Middleware-Apache2-ModSSL/project>
+	:perl_version_from _:main ;
+	:version_from _:main ;
+	:readme_from _:main ;
+	:test_requires "Test::More 0.61"  .
+
+_:main <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName> "lib/Plack/Middleware/Apache2/ModSSL.pm" .
+
+use Test::More tests => 1;
+BEGIN { use_ok('Plack::Middleware::Apache2::ModSSL') };
+
+use Test::More;
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();
+

File xt/02pod_coverage.t

+use Test::More;
+use Test::Pod::Coverage;
+
+my @modules = qw(Plack::Middleware::Apache2::ModSSL);
+pod_coverage_ok($_, "$_ is covered")
+	foreach @modules;
+done_testing(scalar @modules);
+

File xt/03meta_uptodate.t

+use Test::More tests => 1;
+use Test::RDF::DOAP::Version;
+doap_version_ok('Plack-Middleware-Apache2-ModSSL', 'Plack::Middleware::Apache::ModSSL');
+
+use Test::EOL;
+all_perl_files_ok();