[Bps-public-commit] rt-extension-rest2 branch, master, updated. caee840b6bced796c66fa036ad8d7f3973fa46af

Shawn Moore shawn at bestpractical.com
Fri Jul 7 12:04:06 EDT 2017


The branch, master has been updated
       via  caee840b6bced796c66fa036ad8d7f3973fa46af (commit)
       via  af07b94d41a70ae3fb6662cc1071554c648ffbd3 (commit)
      from  e0ddc9ef455296f8a3fa1c0a1a25b973bcb104a6 (commit)

Summary of changes:
 lib/RT/Extension/REST2/Middleware/Auth.pm      | 10 ++++-
 lib/RT/Extension/REST2/Resource/Download/CF.pm | 51 --------------------------
 2 files changed, 8 insertions(+), 53 deletions(-)
 delete mode 100644 lib/RT/Extension/REST2/Resource/Download/CF.pm

- Log -----------------------------------------------------------------
commit af07b94d41a70ae3fb6662cc1071554c648ffbd3
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Fri Jul 7 15:48:34 2017 +0000

    Remove unused Download::CF resource

diff --git a/lib/RT/Extension/REST2/Resource/Download/CF.pm b/lib/RT/Extension/REST2/Resource/Download/CF.pm
deleted file mode 100644
index 5c48762..0000000
--- a/lib/RT/Extension/REST2/Resource/Download/CF.pm
+++ /dev/null
@@ -1,51 +0,0 @@
-package RT::Extension::REST2::Resource::Download::CF;
-use strict;
-use warnings;
-
-use Moose;
-use namespace::autoclean;
-
-extends 'RT::Extension::REST2::Resource::Record';
-
-has 'content_type' => (
-    is          => 'ro',
-    isa         => 'Str',
-    required    => 1,
-    lazy_build  => 1,
-);
-
-sub _build_record_class { "RT::ObjectCustomFieldValue" }
-sub _build_content_type {
-    my $self = shift;
-    return $self->record->ContentType || 'text/plain';
-}
-
-sub allowed_methods { [ 'GET', 'HEAD' ] }
-
-sub content_types_provided { [
-    { $_[0]->content_type => 'to_content' },
-] }
-
-sub charsets_provided {
-    my $self = shift;
-    # We need to serve both binary data (sans charset) and textual data (using
-    # utf-8).  The RT::I18N helper is used in _DecodeLOB (via LargeContent),
-    # and determines if the data returned by LargeContent has been decoded from
-    # UTF-8 bytes to characters.  If not, the data remains bytes and we serve
-    # no charset.
-    if ( RT::I18N::IsTextualContentType( $self->content_type ) ) {
-        return [ 'utf-8' ];
-    } else {
-        return [];
-    }
-}
-sub default_charset { $_[0]->charsets_provided->[0] }
-
-sub to_content {
-    my $self = shift;
-    return $self->record->LargeContent;
-}
-
-__PACKAGE__->meta->make_immutable;
-
-1;

commit caee840b6bced796c66fa036ad8d7f3973fa46af
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Fri Jul 7 16:03:29 2017 +0000

    Allow passing auth token via ?token= query param
    
    for web hook providers etc that may not allow you to specify headers

diff --git a/lib/RT/Extension/REST2/Middleware/Auth.pm b/lib/RT/Extension/REST2/Middleware/Auth.pm
index 3745b6c..af51ac4 100644
--- a/lib/RT/Extension/REST2/Middleware/Auth.pm
+++ b/lib/RT/Extension/REST2/Middleware/Auth.pm
@@ -56,8 +56,14 @@ sub login_from_authtoken {
     # needs RT::Authen::Token extension
     return unless RT::AuthToken->can('Create');
 
-    if (($env->{HTTP_AUTHORIZATION}||'') =~ /^token (.*)$/i) {
-        my ($user_obj, $token) = RT::Authen::Token->UserForAuthString($1);
+    # Authorization: token 1-14-abcdef header
+    my ($authstring) = ($env->{HTTP_AUTHORIZATION}||'') =~ /^token (.*)$/i;
+
+    # or ?token=1-14-abcdef query parameter
+    $authstring ||= Plack::Request->new($env)->parameters->{token};
+
+    if ($authstring) {
+        my ($user_obj, $token) = RT::Authen::Token->UserForAuthString($authstring);
         return $user_obj;
     }
 

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list