Skip to content

Commit 16332d0

Browse files
committed
Merge branch 'dev' of github.com:appbaseio/arc into dev
2 parents 9a3d9d4 + 9a74872 commit 16332d0

14 files changed

Lines changed: 157 additions & 281 deletions

File tree

arc.log

Lines changed: 0 additions & 208 deletions
This file was deleted.

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ require (
1313
github.com/robfig/cron v1.1.0
1414
github.com/rogpeppe/go-internal v1.2.2 // indirect
1515
github.com/rs/cors v1.6.0
16-
github.com/siddharthlatest/mustache v0.0.0-20160118163553-00029677272d
1716
github.com/smartystreets/goconvey v1.6.4
18-
github.com/stretchr/testify v1.3.0
1917
github.com/ulule/limiter v2.2.0+incompatible
2018
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
2119
gopkg.in/natefinch/lumberjack.v2 v2.0.0
2220
gopkg.in/olivere/elastic.v6 v6.2.26
2321
)
22+
23+
go 1.13

go.sum

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
3333
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
3434
github.com/fatih/structs v1.0.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
3535
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
36-
github.com/fortytw2/leaktest v1.2.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
3736
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
3837
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
3938
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
@@ -227,6 +226,7 @@ github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
227226
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
228227
github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA=
229228
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
229+
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
230230
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
231231
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
232232
github.com/gorilla/mux v1.6.2 h1:Pgr17XVTNXAk3q/r4CpKzC5xBM/qW1uVLV+IhRZpIIk=
@@ -266,13 +266,14 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
266266
github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
267267
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
268268
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
269+
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
269270
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
270271
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
271272
github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
273+
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
272274
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
273275
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
274276
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
275-
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
276277
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe h1:W/GaMY0y69G4cFlmsC6B9sbuo2fP8OFP1ABjt4kPz+w=
277278
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
278279
github.com/markbates/deplist v1.0.4/go.mod h1:gRRbPbbuA8TmMiRvaOzUlRfzfjeCCBqX2A6arxN01MM=
@@ -354,7 +355,6 @@ github.com/shurcooL/highlight_diff v0.0.0-20170515013008-09bb4053de1b/go.mod h1:
354355
github.com/shurcooL/highlight_go v0.0.0-20170515013102-78fb10f4a5f8/go.mod h1:UDKB5a1T23gOMUJrI+uSuH0VRDStOiUVSjBTRDVBVag=
355356
github.com/shurcooL/octicon v0.0.0-20180602230221-c42b0e3b24d9/go.mod h1:eWdoE5JD4R5UVWDucdOPg1g2fqQRq78IQa9zlOV1vpQ=
356357
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
357-
github.com/siddharthlatest/mustache v0.0.0-20160118163553-00029677272d/go.mod h1:ej02m5sGsrB5WBnM5xLGTfxUInBAbfNFPAsoJxBjn50=
358358
github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
359359
github.com/sirupsen/logrus v1.1.0/go.mod h1:zrgwTnHtNr00buQ1vSptGe8m1f/BbgsPukg8qsT7A+A=
360360
github.com/sirupsen/logrus v1.1.1/go.mod h1:zrgwTnHtNr00buQ1vSptGe8m1f/BbgsPukg8qsT7A+A=
@@ -459,6 +459,7 @@ golang.org/x/sys v0.0.0-20190102155601-82a175fd1598/go.mod h1:STP8DvDyc/dI5b8T5h
459459
golang.org/x/sys v0.0.0-20190116161447-11f53e031339/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
460460
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
461461
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
462+
golang.org/x/sys v0.0.0-20191008105621-543471e840be h1:QAcqgptGM8IQBC9K/RC4o+O9YmqEm0diQn9QmZw/0mU=
462463
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
463464
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
464465
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -501,6 +502,7 @@ gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4
501502
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
502503
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
503504
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
505+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
504506
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
505507
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
506508
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=

model/permission/permission.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type Permission struct {
4848
Description string `json:"description"`
4949
Includes []string `json:"include_fields"`
5050
Excludes []string `json:"exclude_fields"`
51+
Expired bool `json:"expired"`
5152
}
5253

5354
// Limits defines the rate limits for each category.

plugins/auth/e2e_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ var createPermissionResponse = map[string]interface{}{
6767
"description": "TEST PERMISSION WITH ROLE",
6868
"include_fields": nil,
6969
"exclude_fields": nil,
70+
"expired": false,
7071
}
7172

7273
var updatePermissionsRequest = map[string]interface{}{

plugins/elasticsearch/routes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111
"sync"
1212

1313
"github.com/appbaseio/arc/middleware"
14-
"github.com/appbaseio/arc/plugins"
1514
"github.com/appbaseio/arc/model/acl"
1615
"github.com/appbaseio/arc/model/category"
1716
"github.com/appbaseio/arc/model/op"
17+
"github.com/appbaseio/arc/plugins"
1818
"github.com/appbaseio/arc/util"
1919
"github.com/gobuffalo/packr"
2020
)
@@ -49,7 +49,7 @@ type spec struct {
4949
} `json:"body,omitempty"`
5050
}
5151

52-
func (es *elasticsearch) preprocess(mw [] middleware.Middleware) error {
52+
func (es *elasticsearch) preprocess(mw []middleware.Middleware) error {
5353
files := make(chan string)
5454
apis := make(chan api)
5555

plugins/permissions/dao.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,23 @@ func initPlugin(indexName, mapping string) (*elasticsearch, error) {
5050
return es, nil
5151
}
5252

53+
func applyExpiredField(data []byte) ([]byte, error) {
54+
var rawPermission *permission.Permission
55+
err := json.Unmarshal(data, &rawPermission)
56+
if err != nil {
57+
return nil, fmt.Errorf("unable to un-marshal slice of raw permissions: %v", err)
58+
}
59+
rawPermission.Expired, err = rawPermission.IsExpired()
60+
if err != nil {
61+
return nil, err
62+
}
63+
marshalled, err := json.Marshal(rawPermission)
64+
if err != nil {
65+
return nil, fmt.Errorf("unable to marshal slice of raw permissions: %v", err)
66+
}
67+
return marshalled, nil
68+
}
69+
5370
func (es *elasticsearch) getPermission(ctx context.Context, username string) (*permission.Permission, error) {
5471
raw, err := es.getRawPermission(ctx, username)
5572
if err != nil {

plugins/permissions/dao_es6.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ func (es *elasticsearch) getRawOwnerPermissionsEs6(ctx context.Context, owner st
5151

5252
rawPermissions := []json.RawMessage{}
5353
for _, hit := range resp.Hits.Hits {
54-
rawPermissions = append(rawPermissions, *hit.Source)
54+
rawPermission, err := applyExpiredField(*hit.Source)
55+
if err != nil {
56+
return nil, err
57+
}
58+
rawPermissions = append(rawPermissions, rawPermission)
5559
}
5660

5761
raw, err := json.Marshal(rawPermissions)
@@ -72,12 +76,10 @@ func (es *elasticsearch) getRawPermissionEs6(ctx context.Context, username strin
7276
if err != nil {
7377
return nil, err
7478
}
75-
76-
src, err := response.Source.MarshalJSON()
79+
src, err := applyExpiredField(*response.Source)
7780
if err != nil {
7881
return nil, err
7982
}
80-
8183
return src, nil
8284
}
8385

plugins/permissions/dao_es7.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ func (es *elasticsearch) getRawOwnerPermissionsEs7(ctx context.Context, owner st
5151

5252
rawPermissions := []json.RawMessage{}
5353
for _, hit := range resp.Hits.Hits {
54-
rawPermissions = append(rawPermissions, hit.Source)
54+
rawPermission, err := applyExpiredField(hit.Source)
55+
if err != nil {
56+
return nil, err
57+
}
58+
rawPermissions = append(rawPermissions, rawPermission)
5559
}
5660

5761
raw, err := json.Marshal(rawPermissions)
@@ -72,11 +76,10 @@ func (es *elasticsearch) getRawPermissionEs7(ctx context.Context, username strin
7276
return nil, err
7377
}
7478

75-
src, err := response.Source.MarshalJSON()
79+
src, err := applyExpiredField(response.Source)
7680
if err != nil {
7781
return nil, err
7882
}
79-
8083
return src, nil
8184
}
8285

plugins/permissions/e2e_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ var createPermissionResponse = map[string]interface{}{
6868
"description": "TEST PERMISSION",
6969
"include_fields": nil,
7070
"exclude_fields": nil,
71+
"expired": false,
7172
}
7273

7374
var updatePermissionsRequest = map[string]interface{}{

0 commit comments

Comments
 (0)