From: Tomas Doran Date: Wed, 14 Dec 2011 22:29:49 +0000 (+0000) Subject: Implement new features, in leiu of tests. Bet I got the trinary oprator wrong X-Git-Tag: v1.014~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Authentication-Credential-HTTP.git;a=commitdiff_plain;h=5490d6f6456e8abfa409900ee64ebb5714fd382d Implement new features, in leiu of tests. Bet I got the trinary oprator wrong --- diff --git a/lib/Catalyst/Authentication/Credential/HTTP.pm b/lib/Catalyst/Authentication/Credential/HTTP.pm index da79a9a..13defab 100644 --- a/lib/Catalyst/Authentication/Credential/HTTP.pm +++ b/lib/Catalyst/Authentication/Credential/HTTP.pm @@ -18,6 +18,8 @@ __PACKAGE__->mk_accessors(qw/ realm algorithm use_uri_for + no_unprompted_authorization_required + require_ssl /); our $VERSION = '1.013'; @@ -50,14 +52,24 @@ sub authenticate { my ( $self, $c, $realm, $auth_info ) = @_; my $auth; + $self->authentication_failed( $c, $realm, $auth_info ) + if $self->require_ssl ? $c->req->scheme ne 'https' : 0; + $auth = $self->authenticate_digest($c, $realm, $auth_info) if $self->_is_http_auth_type('digest'); return $auth if $auth; $auth = $self->authenticate_basic($c, $realm, $auth_info) if $self->_is_http_auth_type('basic'); return $auth if $auth; - $self->authorization_required_response($c, $realm, $auth_info); - die $Catalyst::DETACH; + $self->authentication_failed( $c, $realm, $auth_info ); +} + +sub authentication_failed { + my ( $self, $c, $realm, $auth_info ) = @_; + unless (!$self->no_unprompted_authorization_required) { + $self->authorization_required_response($c, $realm, $auth_info); + die $Catalyst::DETACH; + } } sub authenticate_basic {