quickfix for thumbnail generation when using different idp

This commit is contained in:
David Christofas
2021-02-11 15:53:33 +01:00
parent dea1fa87a9
commit 9027864b68
10 changed files with 311 additions and 160 deletions

View File

@@ -0,0 +1,7 @@
Bugfix: Fix thumbnail generation when using different idp
The thumbnail service was relying on a konnectd specific field in the access token.
This logic was now replaced by a service parameter for the username.
https://github.com/owncloud/ocis/issues/1624
https://github.com/owncloud/ocis/pull/1628

View File

@@ -31,6 +31,7 @@ require (
github.com/owncloud/ocis/thumbnails v0.1.6
github.com/owncloud/ocis/web v0.0.0-00010101000000-000000000000
github.com/owncloud/ocis/webdav v0.0.0-00010101000000-000000000000
github.com/refs/pman v0.0.0-20210125101615-7406747552bc
github.com/restic/calens v0.2.0
github.com/rs/zerolog v1.20.0
github.com/spf13/cobra v1.0.0

View File

@@ -32,6 +32,7 @@ require (
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a // indirect
golang.org/x/image v0.0.0-20190802002840-cff245a6509b
google.golang.org/genproto v0.0.0-20200918140846-d0d605568037 // indirect
google.golang.org/protobuf v1.25.0
gopkg.in/square/go-jose.v2 v2.5.1
)

View File

@@ -209,6 +209,8 @@ github.com/cs3org/reva v1.4.1-0.20210111080247-f2b63bfd6825 h1:U6pAVGTjesstz+EXd
github.com/cs3org/reva v1.4.1-0.20210111080247-f2b63bfd6825/go.mod h1:abC1Lo0ZKwkKloomTPZWunV/lUJvewkty1pI41zn2Ic=
github.com/cs3org/reva v1.5.1 h1:GebunCjhHfA3lFLXjQT+3jOUjEXUubk9sr3otOIDGac=
github.com/cs3org/reva v1.5.1/go.mod h1:abC1Lo0ZKwkKloomTPZWunV/lUJvewkty1pI41zn2Ic=
github.com/cs3org/reva v1.5.2-0.20210125114636-0c10b333ee69 h1:HNpnnhoHv/7fUSEuW37clWyPz2x9VqJHuhvWBAHjkEU=
github.com/cs3org/reva v1.5.2-0.20210125114636-0c10b333ee69/go.mod h1:abC1Lo0ZKwkKloomTPZWunV/lUJvewkty1pI41zn2Ic=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

View File

@@ -1,204 +1,351 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: pkg/proto/v0/thumbnails.proto
// versions:
// protoc-gen-go v1.25.0-devel
// protoc v3.14.0
// source: thumbnails.proto
package proto
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// The file types to which the thumbnail cna get encoded to.
type GetRequest_FileType int32
const (
GetRequest_PNG GetRequest_FileType = 0
GetRequest_JPG GetRequest_FileType = 1
GetRequest_PNG GetRequest_FileType = 0 // Represents PNG type
GetRequest_JPG GetRequest_FileType = 1 // Represents JPG type
)
var GetRequest_FileType_name = map[int32]string{
0: "PNG",
1: "JPG",
}
// Enum value maps for GetRequest_FileType.
var (
GetRequest_FileType_name = map[int32]string{
0: "PNG",
1: "JPG",
}
GetRequest_FileType_value = map[string]int32{
"PNG": 0,
"JPG": 1,
}
)
var GetRequest_FileType_value = map[string]int32{
"PNG": 0,
"JPG": 1,
func (x GetRequest_FileType) Enum() *GetRequest_FileType {
p := new(GetRequest_FileType)
*p = x
return p
}
func (x GetRequest_FileType) String() string {
return proto.EnumName(GetRequest_FileType_name, int32(x))
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (GetRequest_FileType) Descriptor() protoreflect.EnumDescriptor {
return file_thumbnails_proto_enumTypes[0].Descriptor()
}
func (GetRequest_FileType) Type() protoreflect.EnumType {
return &file_thumbnails_proto_enumTypes[0]
}
func (x GetRequest_FileType) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use GetRequest_FileType.Descriptor instead.
func (GetRequest_FileType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_e354cb4f8a62b6c2, []int{0, 0}
return file_thumbnails_proto_rawDescGZIP(), []int{0, 0}
}
// A request to retrieve a thumbnail
type GetRequest struct {
Filepath string `protobuf:"bytes,1,opt,name=filepath,proto3" json:"filepath,omitempty"`
Filetype GetRequest_FileType `protobuf:"varint,2,opt,name=filetype,proto3,enum=com.owncloud.ocis.thumbnails.v0.GetRequest_FileType" json:"filetype,omitempty"`
Etag string `protobuf:"bytes,3,opt,name=etag,proto3" json:"etag,omitempty"`
Width int32 `protobuf:"varint,4,opt,name=width,proto3" json:"width,omitempty"`
Height int32 `protobuf:"varint,5,opt,name=height,proto3" json:"height,omitempty"`
Authorization string `protobuf:"bytes,6,opt,name=authorization,proto3" json:"authorization,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// The path to the source image
Filepath string `protobuf:"bytes,1,opt,name=filepath,proto3" json:"filepath,omitempty"`
// The type to which the thumbnail should get encoded to.
Filetype GetRequest_FileType `protobuf:"varint,2,opt,name=filetype,proto3,enum=com.owncloud.ocis.thumbnails.v0.GetRequest_FileType" json:"filetype,omitempty"`
// The etag of the source image
Etag string `protobuf:"bytes,3,opt,name=etag,proto3" json:"etag,omitempty"`
// The width of the thumbnail
Width int32 `protobuf:"varint,4,opt,name=width,proto3" json:"width,omitempty"`
// The height of the thumbnail
Height int32 `protobuf:"varint,5,opt,name=height,proto3" json:"height,omitempty"`
// The authorization token
Authorization string `protobuf:"bytes,6,opt,name=authorization,proto3" json:"authorization,omitempty"`
// The user requesting the resource.
Username string `protobuf:"bytes,7,opt,name=username,proto3" json:"username,omitempty"`
}
func (m *GetRequest) Reset() { *m = GetRequest{} }
func (m *GetRequest) String() string { return proto.CompactTextString(m) }
func (*GetRequest) ProtoMessage() {}
func (x *GetRequest) Reset() {
*x = GetRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_thumbnails_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetRequest) ProtoMessage() {}
func (x *GetRequest) ProtoReflect() protoreflect.Message {
mi := &file_thumbnails_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetRequest.ProtoReflect.Descriptor instead.
func (*GetRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_e354cb4f8a62b6c2, []int{0}
return file_thumbnails_proto_rawDescGZIP(), []int{0}
}
func (m *GetRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetRequest.Unmarshal(m, b)
}
func (m *GetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetRequest.Marshal(b, m, deterministic)
}
func (m *GetRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetRequest.Merge(m, src)
}
func (m *GetRequest) XXX_Size() int {
return xxx_messageInfo_GetRequest.Size(m)
}
func (m *GetRequest) XXX_DiscardUnknown() {
xxx_messageInfo_GetRequest.DiscardUnknown(m)
}
var xxx_messageInfo_GetRequest proto.InternalMessageInfo
func (m *GetRequest) GetFilepath() string {
if m != nil {
return m.Filepath
func (x *GetRequest) GetFilepath() string {
if x != nil {
return x.Filepath
}
return ""
}
func (m *GetRequest) GetFiletype() GetRequest_FileType {
if m != nil {
return m.Filetype
func (x *GetRequest) GetFiletype() GetRequest_FileType {
if x != nil {
return x.Filetype
}
return GetRequest_PNG
}
func (m *GetRequest) GetEtag() string {
if m != nil {
return m.Etag
func (x *GetRequest) GetEtag() string {
if x != nil {
return x.Etag
}
return ""
}
func (m *GetRequest) GetWidth() int32 {
if m != nil {
return m.Width
func (x *GetRequest) GetWidth() int32 {
if x != nil {
return x.Width
}
return 0
}
func (m *GetRequest) GetHeight() int32 {
if m != nil {
return m.Height
func (x *GetRequest) GetHeight() int32 {
if x != nil {
return x.Height
}
return 0
}
func (m *GetRequest) GetAuthorization() string {
if m != nil {
return m.Authorization
func (x *GetRequest) GetAuthorization() string {
if x != nil {
return x.Authorization
}
return ""
}
func (x *GetRequest) GetUsername() string {
if x != nil {
return x.Username
}
return ""
}
// The service response
type GetResponse struct {
Thumbnail []byte `protobuf:"bytes,1,opt,name=thumbnail,proto3" json:"thumbnail,omitempty"`
Mimetype string `protobuf:"bytes,2,opt,name=mimetype,proto3" json:"mimetype,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// The thumbnail as a binary
Thumbnail []byte `protobuf:"bytes,1,opt,name=thumbnail,proto3" json:"thumbnail,omitempty"`
// The mimetype of the thumbnail
Mimetype string `protobuf:"bytes,2,opt,name=mimetype,proto3" json:"mimetype,omitempty"`
}
func (m *GetResponse) Reset() { *m = GetResponse{} }
func (m *GetResponse) String() string { return proto.CompactTextString(m) }
func (*GetResponse) ProtoMessage() {}
func (x *GetResponse) Reset() {
*x = GetResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_thumbnails_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetResponse) ProtoMessage() {}
func (x *GetResponse) ProtoReflect() protoreflect.Message {
mi := &file_thumbnails_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetResponse.ProtoReflect.Descriptor instead.
func (*GetResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_e354cb4f8a62b6c2, []int{1}
return file_thumbnails_proto_rawDescGZIP(), []int{1}
}
func (m *GetResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetResponse.Unmarshal(m, b)
}
func (m *GetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GetResponse.Marshal(b, m, deterministic)
}
func (m *GetResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_GetResponse.Merge(m, src)
}
func (m *GetResponse) XXX_Size() int {
return xxx_messageInfo_GetResponse.Size(m)
}
func (m *GetResponse) XXX_DiscardUnknown() {
xxx_messageInfo_GetResponse.DiscardUnknown(m)
}
var xxx_messageInfo_GetResponse proto.InternalMessageInfo
func (m *GetResponse) GetThumbnail() []byte {
if m != nil {
return m.Thumbnail
func (x *GetResponse) GetThumbnail() []byte {
if x != nil {
return x.Thumbnail
}
return nil
}
func (m *GetResponse) GetMimetype() string {
if m != nil {
return m.Mimetype
func (x *GetResponse) GetMimetype() string {
if x != nil {
return x.Mimetype
}
return ""
}
func init() {
proto.RegisterEnum("com.owncloud.ocis.thumbnails.v0.GetRequest_FileType", GetRequest_FileType_name, GetRequest_FileType_value)
proto.RegisterType((*GetRequest)(nil), "com.owncloud.ocis.thumbnails.v0.GetRequest")
proto.RegisterType((*GetResponse)(nil), "com.owncloud.ocis.thumbnails.v0.GetResponse")
var File_thumbnails_proto protoreflect.FileDescriptor
var file_thumbnails_proto_rawDesc = []byte{
0x0a, 0x10, 0x74, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x73, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x12, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64,
0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x74, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x73,
0x2e, 0x76, 0x30, 0x22, 0x9c, 0x02, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x70, 0x61, 0x74, 0x68, 0x12, 0x50,
0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e,
0x32, 0x34, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e,
0x6f, 0x63, 0x69, 0x73, 0x2e, 0x74, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x73, 0x2e,
0x76, 0x30, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x46, 0x69,
0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x74, 0x79, 0x70, 0x65,
0x12, 0x12, 0x0a, 0x04, 0x65, 0x74, 0x61, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x65, 0x74, 0x61, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x18, 0x04, 0x20,
0x01, 0x28, 0x05, 0x52, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65,
0x69, 0x67, 0x68, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67,
0x68, 0x74, 0x12, 0x24, 0x0a, 0x0d, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x75, 0x74, 0x68, 0x6f,
0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72,
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72,
0x6e, 0x61, 0x6d, 0x65, 0x22, 0x1c, 0x0a, 0x08, 0x46, 0x69, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65,
0x12, 0x07, 0x0a, 0x03, 0x50, 0x4e, 0x47, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x4a, 0x50, 0x47,
0x10, 0x01, 0x22, 0x47, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x74, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x12,
0x1a, 0x0a, 0x08, 0x6d, 0x69, 0x6d, 0x65, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x08, 0x6d, 0x69, 0x6d, 0x65, 0x74, 0x79, 0x70, 0x65, 0x32, 0x7d, 0x0a, 0x10, 0x54,
0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12,
0x69, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x54, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x12,
0x2b, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x6f,
0x63, 0x69, 0x73, 0x2e, 0x74, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x73, 0x2e, 0x76,
0x30, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x63,
0x6f, 0x6d, 0x2e, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x6f, 0x63, 0x69, 0x73,
0x2e, 0x74, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x73, 0x2e, 0x76, 0x30, 0x2e, 0x47,
0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x07, 0x5a, 0x05, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
func init() { proto.RegisterFile("pkg/proto/v0/thumbnails.proto", fileDescriptor_e354cb4f8a62b6c2) }
var (
file_thumbnails_proto_rawDescOnce sync.Once
file_thumbnails_proto_rawDescData = file_thumbnails_proto_rawDesc
)
var fileDescriptor_e354cb4f8a62b6c2 = []byte{
// 309 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0x4f, 0x4f, 0xc2, 0x40,
0x10, 0xc5, 0x2d, 0x50, 0xfe, 0x8c, 0x68, 0xc8, 0xc4, 0x98, 0x86, 0x60, 0x24, 0xc4, 0x03, 0x89,
0x66, 0x21, 0xe8, 0x27, 0xf0, 0x60, 0x13, 0x0f, 0x86, 0x54, 0x4e, 0xde, 0x4a, 0x19, 0xd9, 0x8d,
0x6d, 0x77, 0xa5, 0x53, 0x08, 0x26, 0x26, 0x7e, 0x74, 0xc3, 0x22, 0x45, 0x4f, 0xea, 0x69, 0xe7,
0xfd, 0x76, 0xf2, 0x66, 0xf6, 0x2d, 0x9c, 0x99, 0x97, 0xf9, 0xc0, 0x2c, 0x34, 0xeb, 0xc1, 0x72,
0x38, 0x60, 0x99, 0x27, 0xd3, 0x34, 0x54, 0x71, 0x26, 0x2c, 0xc3, 0xf3, 0x48, 0x27, 0x42, 0xaf,
0xd2, 0x28, 0xd6, 0xf9, 0x4c, 0xe8, 0x48, 0x65, 0xe2, 0x5b, 0xcf, 0x72, 0xd8, 0xfb, 0x28, 0x01,
0xf8, 0xc4, 0x01, 0xbd, 0xe6, 0x94, 0x31, 0xb6, 0xa1, 0xfe, 0xac, 0x62, 0x32, 0x21, 0x4b, 0xcf,
0xe9, 0x3a, 0xfd, 0x46, 0x50, 0x68, 0x1c, 0x6f, 0xef, 0x78, 0x6d, 0xc8, 0x2b, 0x75, 0x9d, 0xfe,
0xf1, 0xe8, 0x46, 0xfc, 0x62, 0x2f, 0xf6, 0xd6, 0xe2, 0x4e, 0xc5, 0x34, 0x59, 0x1b, 0x0a, 0x0a,
0x17, 0x44, 0xa8, 0x10, 0x87, 0x73, 0xaf, 0x6c, 0x27, 0xd9, 0x1a, 0x4f, 0xc0, 0x5d, 0xa9, 0x19,
0x4b, 0xaf, 0xd2, 0x75, 0xfa, 0x6e, 0xb0, 0x15, 0x78, 0x0a, 0x55, 0x49, 0x6a, 0x2e, 0xd9, 0x73,
0x2d, 0xfe, 0x52, 0x78, 0x01, 0x47, 0x61, 0xce, 0x52, 0x2f, 0xd4, 0x5b, 0xc8, 0x4a, 0xa7, 0x5e,
0xd5, 0x5a, 0xfd, 0x84, 0xbd, 0x0e, 0xd4, 0x77, 0xd3, 0xb1, 0x06, 0xe5, 0xf1, 0x83, 0xdf, 0x3a,
0xd8, 0x14, 0xf7, 0x63, 0xbf, 0xe5, 0xf4, 0x7c, 0x38, 0xb4, 0x6b, 0x66, 0x46, 0xa7, 0x19, 0x61,
0x07, 0x1a, 0xc5, 0x1b, 0x6c, 0x06, 0xcd, 0x60, 0x0f, 0x36, 0x01, 0x25, 0x2a, 0xd9, 0x87, 0xd0,
0x08, 0x0a, 0x3d, 0x7a, 0x87, 0xd6, 0x64, 0xd7, 0xf8, 0x48, 0x8b, 0xa5, 0x8a, 0x08, 0x15, 0x34,
0x7d, 0xe2, 0x02, 0xe3, 0xe5, 0x3f, 0x22, 0x6b, 0x5f, 0xfd, 0xad, 0x79, 0xbb, 0xf8, 0x6d, 0xed,
0xc9, 0xb5, 0x9f, 0x3e, 0xad, 0xda, 0xe3, 0xfa, 0x33, 0x00, 0x00, 0xff, 0xff, 0xb1, 0x29, 0x25,
0xcc, 0x1c, 0x02, 0x00, 0x00,
func file_thumbnails_proto_rawDescGZIP() []byte {
file_thumbnails_proto_rawDescOnce.Do(func() {
file_thumbnails_proto_rawDescData = protoimpl.X.CompressGZIP(file_thumbnails_proto_rawDescData)
})
return file_thumbnails_proto_rawDescData
}
var file_thumbnails_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_thumbnails_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_thumbnails_proto_goTypes = []interface{}{
(GetRequest_FileType)(0), // 0: com.owncloud.ocis.thumbnails.v0.GetRequest.FileType
(*GetRequest)(nil), // 1: com.owncloud.ocis.thumbnails.v0.GetRequest
(*GetResponse)(nil), // 2: com.owncloud.ocis.thumbnails.v0.GetResponse
}
var file_thumbnails_proto_depIdxs = []int32{
0, // 0: com.owncloud.ocis.thumbnails.v0.GetRequest.filetype:type_name -> com.owncloud.ocis.thumbnails.v0.GetRequest.FileType
1, // 1: com.owncloud.ocis.thumbnails.v0.ThumbnailService.GetThumbnail:input_type -> com.owncloud.ocis.thumbnails.v0.GetRequest
2, // 2: com.owncloud.ocis.thumbnails.v0.ThumbnailService.GetThumbnail:output_type -> com.owncloud.ocis.thumbnails.v0.GetResponse
2, // [2:3] is the sub-list for method output_type
1, // [1:2] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_thumbnails_proto_init() }
func file_thumbnails_proto_init() {
if File_thumbnails_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_thumbnails_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_thumbnails_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_thumbnails_proto_rawDesc,
NumEnums: 1,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_thumbnails_proto_goTypes,
DependencyIndexes: file_thumbnails_proto_depIdxs,
EnumInfos: file_thumbnails_proto_enumTypes,
MessageInfos: file_thumbnails_proto_msgTypes,
}.Build()
File_thumbnails_proto = out.File
file_thumbnails_proto_rawDesc = nil
file_thumbnails_proto_goTypes = nil
file_thumbnails_proto_depIdxs = nil
}

View File

@@ -1,5 +1,5 @@
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: pkg/proto/v0/thumbnails.proto
// source: thumbnails.proto
package proto
@@ -11,6 +11,7 @@ import (
import (
context "context"
api "github.com/micro/go-micro/v2/api"
client "github.com/micro/go-micro/v2/client"
server "github.com/micro/go-micro/v2/server"
)
@@ -27,13 +28,21 @@ var _ = math.Inf
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// Reference imports to suppress errors if they are not otherwise used.
var _ api.Endpoint
var _ context.Context
var _ client.Option
var _ server.Option
// Api Endpoints for ThumbnailService service
func NewThumbnailServiceEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for ThumbnailService service
type ThumbnailService interface {
// Generates the thumbnail and returns it.
GetThumbnail(ctx context.Context, in *GetRequest, opts ...client.CallOption) (*GetResponse, error)
}
@@ -62,6 +71,7 @@ func (c *thumbnailService) GetThumbnail(ctx context.Context, in *GetRequest, opt
// Server API for ThumbnailService service
type ThumbnailServiceHandler interface {
// Generates the thumbnail and returns it.
GetThumbnail(context.Context, *GetRequest, *GetResponse) error
}

View File

@@ -28,6 +28,8 @@ message GetRequest {
int32 height = 5;
// The authorization token
string authorization = 6;
// The user requesting the resource.
string username = 7;
}
// The service response

View File

@@ -4,14 +4,11 @@ import (
"context"
"image"
"gopkg.in/square/go-jose.v2/jwt"
merrors "github.com/micro/go-micro/v2/errors"
"github.com/owncloud/ocis/ocis-pkg/log"
v0proto "github.com/owncloud/ocis/thumbnails/pkg/proto/v0"
"github.com/owncloud/ocis/thumbnails/pkg/thumbnail"
"github.com/owncloud/ocis/thumbnails/pkg/thumbnail/imgsource"
"github.com/pkg/errors"
)
// NewService returns a service implementation for Service.
@@ -56,9 +53,9 @@ func (g Thumbnail) GetThumbnail(ctx context.Context, req *v0proto.GetRequest, rs
if auth == "" {
return merrors.BadRequest(g.serviceID, "authorization is missing")
}
username, err := usernameFromAuthorization(auth)
if err != nil {
return merrors.InternalServerError(g.serviceID, "could not get username: %v", err.Error())
username := req.Username
if username == "" {
return merrors.BadRequest(g.serviceID, "username missing in request")
}
tr := thumbnail.Request{
@@ -92,22 +89,3 @@ func (g Thumbnail) GetThumbnail(ctx context.Context, req *v0proto.GetRequest, rs
rsp.Mimetype = tr.Encoder.MimeType()
return nil
}
func usernameFromAuthorization(auth string) (string, error) {
tokenString := auth[len("Bearer "):] // strip the bearer prefix
var claims map[string]interface{}
token, err := jwt.ParseSigned(tokenString)
if err != nil {
return "", errors.Wrap(err, "could not parse auth token")
}
err = token.UnsafeClaimsWithoutVerification(&claims)
if err != nil {
return "", errors.Wrap(err, "could not get claims from auth token")
}
identityMap := claims["kc.identity"].(map[string]interface{})
username := identityMap["kc.i.un"].(string)
return username, nil
}

View File

@@ -25,6 +25,7 @@ type Request struct {
Width int
Height int
Authorization string
Username string
}
// NewRequest extracts all required parameters from a http request.
@@ -54,6 +55,7 @@ func NewRequest(r *http.Request) (Request, error) {
Width: width,
Height: height,
Authorization: authorization,
Username: chi.URLParam(r, "user"),
}
return tr, nil

View File

@@ -64,6 +64,7 @@ func (g Webdav) Thumbnail(w http.ResponseWriter, r *http.Request) {
Width: int32(tr.Width),
Height: int32(tr.Height),
Authorization: tr.Authorization,
Username: tr.Username,
})
if err != nil {
w.WriteHeader(http.StatusBadRequest)