use strict;
use base qw/Class::Accessor::Fast/;
-use NEXT;
+use MRO::Compat;
-our $VERSION = '0.07';
+our $VERSION = '0.06_01';
__PACKAGE__->mk_accessors( qw/_require_ssl _allow_ssl _ssl_strip_output/ );
# Do not redirect static files (only works with Static::Simple)
if ( $c->isa( "Catalyst::Plugin::Static::Simple" ) ) {
- return $c->NEXT::finalize(@_) if $c->_static_file;
+ return $c->next::method(@_) if $c->_static_file;
}
# redirect back to non-SSL mode
$c->res->body( '' );
}
- return $c->NEXT::finalize(@_);
+ return $c->next::method(@_);
}
sub setup {
my $c = shift;
- $c->NEXT::setup(@_);
+ $c->next::method(@_);
# disable the plugin when running under certain engines which don't
# support SSL
sub _redirect_uri {
my ( $c, $type ) = @_;
- # XXX: Cat needs a $c->req->host method...
- # until then, strip off the leading protocol from base
if ( !$c->config->{require_ssl}->{$type} ) {
- my $host = $c->req->base;
- $host =~ s/^http(s?):\/\///;
- $c->config->{require_ssl}->{$type} = $host;
+ my $req_uri = $c->req->uri;
+ $c->config->{require_ssl}->{$type} =
+ join(':', $req_uri->host, $req_uri->_port);
}
- if ( $c->config->{require_ssl}->{$type} !~ /\/$/xms ) {
- $c->config->{require_ssl}->{$type} .= '/';
- }
+ $c->config->{require_ssl}->{$type} =~ s/\/+$//;
+
+ my $redir = $c->req->uri->clone;
+ $redir->scheme($type);
+ $redir->host_port($c->config->{require_ssl}->{$type});
- my $redir
- = $type . '://' . $c->config->{require_ssl}->{$type} . $c->req->path;
-
- if ( scalar $c->req->param ) {
- my @params;
- foreach my $arg ( sort keys %{ $c->req->params } ) {
- if ( ref $c->req->params->{$arg} ) {
- my $list = $c->req->params->{$arg};
- push @params, map { "$arg=" . $_ } sort @{$list};
- }
- else {
- push @params, "$arg=" . $c->req->params->{$arg};
- }
- }
- $redir .= '?' . join( '&', @params );
- }
-
if ( $c->config->{require_ssl}->{no_cache} ) {
delete $c->config->{require_ssl}->{$type};
}
=head1 DESCRIPTION
+B<Note:> This module is considered to be deprecated for most purposes. Consider
+using L<Catalyst::ActionRole::RequireSSL> instead.
+
Use this plugin if you wish to selectively force SSL mode on some of your web
pages, for example a user login form or shopping cart.
=head1 SEE ALSO
-L<Catalyst>, L<Catalyst::Plugin::Static::Simple>
+L<Catalyst>, L<Catalyst::ActionRole::RequireSSL>,
+L<Catalyst::Plugin::Static::Simple>
=head1 AUTHOR