Skip to content

Commit

Permalink
Merge pull request #472 from alfrunes/MEN-4511
Browse files Browse the repository at this point in the history
jwt: Include 'mender.addons' claim for listing tenant addons
  • Loading branch information
tranchitella committed Mar 17, 2021
2 parents 22dee2e + 92b894a commit 74362f9
Show file tree
Hide file tree
Showing 482 changed files with 95,593 additions and 214 deletions.
102 changes: 58 additions & 44 deletions LIC_FILES_CHKSUM.sha256
Original file line number Diff line number Diff line change
@@ -1,74 +1,88 @@
#
# Apache-2.0
09e8a9bcec8067104652c168685ab0931e7868f9c8284b66f5ae6edae5f1130b vendor/github.com/gomodule/redigo/LICENSE
c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 vendor/go.opentelemetry.io/otel/LICENSE
b4acfcfa2a0ba1a8c82ec3965fbcee886cff8394ca4214e0ddac0a36beb1e05a LICENSE
d5a55eaa82e2c109b8bcadfa66139497511b80d665668264f155b5a45086b086 vendor/github.com/mendersoftware/go-lib-micro/LICENSE
cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30 vendor/github.com/aws/aws-sdk-go/LICENSE.txt
f7a4d9fa675c9347d97d6cb7b3142f733a828e8884eef461f30601f797f8248a vendor/github.com/Azure/go-autorest/autorest/to/LICENSE
f7a4d9fa675c9347d97d6cb7b3142f733a828e8884eef461f30601f797f8248a vendor/github.com/Azure/go-autorest/LICENSE
09e8a9bcec8067104652c168685ab0931e7868f9c8284b66f5ae6edae5f1130b vendor/github.com/gomodule/redigo/LICENSE
03cfaf331a260694d06227a589cdd2b5fcfab474697b72e250736696c313655a vendor/github.com/jmespath/go-jmespath/LICENSE
e31497e5f27700c6c7f25c7831641d0af1df47c3d4c6c3699d12d74d75fd0b33 vendor/github.com/magefile/mage/LICENSE
3eb823230e5d112e1bd032ccc82ae765cf676d0d6d46a1a1daa2d658b3005b67 vendor/github.com/mendersoftware/go-lib-micro/LICENSE
c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 vendor/github.com/modern-go/concurrent/LICENSE
c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 vendor/github.com/modern-go/reflect2/LICENSE
5e3400b93bbb099e83e52bab885e7441750673c21f97988ca3f1240639b63283 vendor/github.com/spf13/afero/LICENSE.txt
09e8a9bcec8067104652c168685ab0931e7868f9c8284b66f5ae6edae5f1130b vendor/github.com/xdg/scram/LICENSE
09e8a9bcec8067104652c168685ab0931e7868f9c8284b66f5ae6edae5f1130b vendor/github.com/xdg/stringprep/LICENSE
c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 vendor/go.mongodb.org/mongo-driver/LICENSE
c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 vendor/go.opentelemetry.io/otel/LICENSE
f6918bd93ffe07f4b2c61b8287c32cb3122e08aed0be50f1c7d0eddc87877a8f vendor/gopkg.in/ini.v1/LICENSE
f7a4d9fa675c9347d97d6cb7b3142f733a828e8884eef461f30601f797f8248a vendor/github.com/Azure/go-autorest/autorest/to/LICENSE
f7a4d9fa675c9347d97d6cb7b3142f733a828e8884eef461f30601f797f8248a vendor/github.com/Azure/go-autorest/LICENSE
03cfaf331a260694d06227a589cdd2b5fcfab474697b72e250736696c313655a vendor/github.com/jmespath/go-jmespath/LICENSE
cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30 vendor/github.com/aws/aws-sdk-go/LICENSE.txt
b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1 vendor/gopkg.in/yaml.v2/LICENSE
#
# BSD-2-Clause
60f543bf667cb2081ce1aff22e24a4f1d6b2a9119783796551b35ecd6830753a vendor/github.com/go-redis/redis/v8/LICENSE
e45788cee53174eee4d7938484bedca0e66dcac6e92bec354b410273bdb5f6e7 vendor/github.com/magiconair/properties/LICENSE
8d427fd87bc9579ea368fde3d49f9ca22eac857f91a9dec7e3004bdfab7dee86 vendor/github.com/pkg/errors/LICENSE
fe60e0cc90e88f12c814adb7dc88df6791c6ec6798d8c856b7d5ad1b805b4f10 vendor/github.com/mendersoftware/go-lib-micro/mongo/dbtest/LICENSE
60f543bf667cb2081ce1aff22e24a4f1d6b2a9119783796551b35ecd6830753a vendor/github.com/go-redis/redis/v8/LICENSE
8d427fd87bc9579ea368fde3d49f9ca22eac857f91a9dec7e3004bdfab7dee86 vendor/github.com/pkg/errors/LICENSE
75e1ca97a84a9da6051dee0114333388216f2c4a5a028296b882ff3d57274735 vendor/github.com/russross/blackfriday/v2/LICENSE.txt
#
# BSD-3-Clause
b8514c577c1c4b46cee454d5a882b15fa411e72c5bd7f801f241591789fce61a vendor/github.com/spf13/pflag/LICENSE
2eb550be6801c1ea434feba53bf6d12e7c71c90253e0a9de4a4f46cf88b56477 vendor/github.com/pmezard/go-difflib/LICENSE
2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 vendor/golang.org/x/sys/LICENSE
2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 vendor/golang.org/x/crypto/LICENSE
8407b13e462f755c06db3db3a034dc1fdc9157af19c6ea8986e7d5aecf4126b3 vendor/gopkg.in/tomb.v2/LICENSE
2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 vendor/golang.org/x/text/LICENSE
2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 vendor/github.com/aws/aws-sdk-go/internal/sync/singleflight/LICENSE
daf1770cc70fdaca5fdd6ee52f9a8a68a9ba2041380714e1fb5ab3e349feb566 vendor/github.com/fsnotify/fsnotify/LICENSE
8778a9fc1eaffb03ab873caae251df2d224f6b5502be8777d3cd573a4dd43903 vendor/github.com/golang/protobuf/LICENSE
f69f157b0be75da373605dbc8bbf142e8924ee82d8f44f11bcaf351335bf98cf vendor/github.com/golang/snappy/LICENSE
f69f157b0be75da373605dbc8bbf142e8924ee82d8f44f11bcaf351335bf98cf vendor/github.com/klauspost/compress/snappy/LICENSE
0a8d61ed3cbfd5312326e8126c31ce9c627a283adc99131b56896d29ada04b2d vendor/github.com/google/uuid/LICENSE
16f848582e4b276a7392cd34496b7a33d6f65c0e190c163ff3a056a7c61219ce vendor/github.com/klauspost/compress/LICENSE
2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 vendor/golang.org/x/sync/LICENSE
f69f157b0be75da373605dbc8bbf142e8924ee82d8f44f11bcaf351335bf98cf vendor/github.com/klauspost/compress/snappy/LICENSE
2eb550be6801c1ea434feba53bf6d12e7c71c90253e0a9de4a4f46cf88b56477 vendor/github.com/pmezard/go-difflib/LICENSE
b8514c577c1c4b46cee454d5a882b15fa411e72c5bd7f801f241591789fce61a vendor/github.com/spf13/pflag/LICENSE
2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 vendor/golang.org/x/crypto/LICENSE
2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 vendor/golang.org/x/net/LICENSE
75e1ca97a84a9da6051dee0114333388216f2c4a5a028296b882ff3d57274735 vendor/github.com/russross/blackfriday/v2/LICENSE.txt
2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 vendor/github.com/aws/aws-sdk-go/internal/sync/singleflight/LICENSE
daf1770cc70fdaca5fdd6ee52f9a8a68a9ba2041380714e1fb5ab3e349feb566 vendor/github.com/fsnotify/fsnotify/LICENSE
2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 vendor/golang.org/x/sync/LICENSE
2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 vendor/golang.org/x/sys/LICENSE
2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 vendor/golang.org/x/text/LICENSE
4835612df0098ca95f8e7d9e3bffcb02358d435dbb38057c844c99d7f725eb20 vendor/google.golang.org/protobuf/LICENSE
8407b13e462f755c06db3db3a034dc1fdc9157af19c6ea8986e7d5aecf4126b3 vendor/gopkg.in/tomb.v2/LICENSE
#
# ISC
1b93a317849ee09d3d7e4f1d20c2b78ddb230b4becb12d7c224c927b9d470251 vendor/github.com/davecgh/go-spew/LICENSE
#
# MIT
9964909ed0def8840643886cdc465b063b5978827bac01b886b15a47488064d4 vendor/github.com/alicebob/miniredis/LICENSE
260ffdb7a4ba43069407382e611dab0797bcdabad46deb3d25b36af7f8204f66 vendor/github.com/yuin/gopher-lua/LICENSE
012d0f6caf604aedba723982c0d8a28f664ecd957de5131bc22c87a0d36b7115 vendor/github.com/asaskevich/govalidator/LICENSE
51a0c9ec7f8b7634181b8d4c03e5b5d204ac21d6e72f46c313973424664b2e6b vendor/github.com/sirupsen/logrus/LICENSE
feb6d17a0e7a64e5ab0f7e2b0e0ee3e69c1a6396626fd554dc0cddaa06851b44 vendor/github.com/spf13/viper/LICENSE
feb6d17a0e7a64e5ab0f7e2b0e0ee3e69c1a6396626fd554dc0cddaa06851b44 vendor/github.com/spf13/cast/LICENSE
feb6d17a0e7a64e5ab0f7e2b0e0ee3e69c1a6396626fd554dc0cddaa06851b44 vendor/github.com/spf13/jwalterweatherman/LICENSE
409777def58db7e220011d266bb963259b5d45fc490e58a0d97acad2b591609a vendor/github.com/ant0ine/go-json-rest/LICENSE
22adc4abdece712a737573672f082fd61ac2b21df878efb87ffcff4354a07f26 vendor/github.com/mitchellh/mapstructure/LICENSE
f8e536c1c7b695810427095dc85f5f80d44ff7c10535e8a9486cf393e2599189 vendor/github.com/stretchr/testify/LICENSE
012d0f6caf604aedba723982c0d8a28f664ecd957de5131bc22c87a0d36b7115 vendor/github.com/asaskevich/govalidator/LICENSE
a55959c4e3e8917bfa857359bb641115336276a6cc97408fd8197e079fb18470 vendor/github.com/cpuguy83/go-md2man/v2/LICENSE.md
f566a9f97bacdaf00d9f21dd991e81dc11201c4e016c86b470799429a1c9a79c vendor/github.com/cespare/xxhash/v2/LICENSE.txt
f71d43124a8b70fbaef7c835d1639e89a7acdb252b05dda35652247902880724 vendor/github.com/dgrijalva/jwt-go/LICENSE
92a328e1d5f3269b42e2ce32b4494eafdb3132f204a911c5c95cf3d8465490e4 vendor/github.com/satori/go.uuid/LICENSE
b2663894033a05fd80261176cd8da1d72546e25842d5c1abcc852ca23b6b61b0 vendor/github.com/stretchr/objx/LICENSE
da277af11b85227490377fbcac6afccc68be560c4fff36ac05ca62de55345fd7 vendor/github.com/urfave/cli/LICENSE
a2e6011b982212228008c4386616a4818eb5fdf9ea5805b7a90500e6ce895aaf vendor/github.com/pelletier/go-toml/LICENSE
11f46ac1bc076fc405c06fd087226e5dd87b9c2e6b8dfda5153c79b5b6f01362 vendor/github.com/dgryski/go-rendezvous/LICENSE
03458b6d5828e1be1127ca2adf122572eb574fc47b56190c3b38203b8b2a98d0 vendor/github.com/gin-contrib/sse/LICENSE
03458b6d5828e1be1127ca2adf122572eb574fc47b56190c3b38203b8b2a98d0 vendor/github.com/gin-gonic/gin/LICENSE
a1a5ca382f9e8c646fa05240a74a6554bbc3084b5675f84c9eaafd3d95686612 vendor/github.com/go-playground/locales/LICENSE
a55d0c6e1a35ee6cf13afb4bbc3c8801cc570d7ac8edcd5e4503892f1c7ff4f7 vendor/github.com/go-playground/universal-translator/LICENSE
9e321f6a1db81616a6c344d3aefddf9834fef23bdd913eae0db283dfa6753dff vendor/github.com/go-playground/validator/v10/LICENSE
9e203bd56d54ad11a8106e63e7a738363634f23ac91e14bddb2e35c5e7545a72 vendor/github.com/go-stack/stack/LICENSE.md
3247931083f058b00760a3c32a9ca0962c05e4d562ad2ffcc1753451fa8d4486 vendor/github.com/json-iterator/go/LICENSE
f566a9f97bacdaf00d9f21dd991e81dc11201c4e016c86b470799429a1c9a79c vendor/github.com/klauspost/compress/zstd/internal/xxhash/LICENSE.txt
a55959c4e3e8917bfa857359bb641115336276a6cc97408fd8197e079fb18470 vendor/github.com/cpuguy83/go-md2man/v2/LICENSE.md
fe81a9072afbfe0fe32b0bc99a852d697d14fbbca99b0b1878ac8f5dcbdd6ee6 vendor/github.com/leodido/go-urn/LICENSE
08eab1118c80885fa1fa6a6dd7303f65a379fcb3733e063d20d1bbc2c76e6fa1 vendor/github.com/mattn/go-isatty/LICENSE
22adc4abdece712a737573672f082fd61ac2b21df878efb87ffcff4354a07f26 vendor/github.com/mitchellh/mapstructure/LICENSE
a2e6011b982212228008c4386616a4818eb5fdf9ea5805b7a90500e6ce895aaf vendor/github.com/pelletier/go-toml/LICENSE
92a328e1d5f3269b42e2ce32b4494eafdb3132f204a911c5c95cf3d8465490e4 vendor/github.com/satori/go.uuid/LICENSE
c8024e31c1de453fea90f22a221968835cc7af9d520274a2576c9ec9976055b0 vendor/github.com/shurcooL/sanitized_anchor_name/LICENSE
51a0c9ec7f8b7634181b8d4c03e5b5d204ac21d6e72f46c313973424664b2e6b vendor/github.com/sirupsen/logrus/LICENSE
feb6d17a0e7a64e5ab0f7e2b0e0ee3e69c1a6396626fd554dc0cddaa06851b44 vendor/github.com/spf13/cast/LICENSE
feb6d17a0e7a64e5ab0f7e2b0e0ee3e69c1a6396626fd554dc0cddaa06851b44 vendor/github.com/spf13/jwalterweatherman/LICENSE
feb6d17a0e7a64e5ab0f7e2b0e0ee3e69c1a6396626fd554dc0cddaa06851b44 vendor/github.com/spf13/viper/LICENSE
b2663894033a05fd80261176cd8da1d72546e25842d5c1abcc852ca23b6b61b0 vendor/github.com/stretchr/objx/LICENSE
f8e536c1c7b695810427095dc85f5f80d44ff7c10535e8a9486cf393e2599189 vendor/github.com/stretchr/testify/LICENSE
1fd29c692f599736d92f7c02b7826836c0d2ccc838689b21822f4ce0253c39df vendor/github.com/subosito/gotenv/LICENSE
11f46ac1bc076fc405c06fd087226e5dd87b9c2e6b8dfda5153c79b5b6f01362 vendor/github.com/dgryski/go-rendezvous/LICENSE
f566a9f97bacdaf00d9f21dd991e81dc11201c4e016c86b470799429a1c9a79c vendor/github.com/cespare/xxhash/v2/LICENSE.txt
# MIT + Apache
d18f6323b71b0b768bb5e9616e36da390fbd39369a81807cca352de4e4e6aa0b vendor/gopkg.in/yaml.v3/LICENSE
#
# LGPL3 with static linking exception.
b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1 vendor/gopkg.in/yaml.v2/LICENSE
# Addendum to the above.
65bffcb78f7d0f57b2e18dcd728d398a86a21832adb61a25c35cc7363e107d19 vendor/github.com/ugorji/go/codec/LICENSE
da277af11b85227490377fbcac6afccc68be560c4fff36ac05ca62de55345fd7 vendor/github.com/urfave/cli/LICENSE
260ffdb7a4ba43069407382e611dab0797bcdabad46deb3d25b36af7f8204f66 vendor/github.com/yuin/gopher-lua/LICENSE
a94710b55e03b5285f77d048c5ba61bb9d6ee04a06c0eb90e68821e11b0c707a vendor/gopkg.in/yaml.v2/LICENSE.libyaml
d18f6323b71b0b768bb5e9616e36da390fbd39369a81807cca352de4e4e6aa0b vendor/gopkg.in/yaml.v3/LICENSE
#
# MPL 2.0
# MPL-2.0
bef1747eda88b9ed46e94830b0d978c3499dad5dfe38d364971760881901dadd vendor/github.com/hashicorp/hcl/LICENSE
# ISC
1b93a317849ee09d3d7e4f1d20c2b78ddb230b4becb12d7c224c927b9d470251 vendor/github.com/davecgh/go-spew/LICENSE
#
# Unlicense
7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c vendor/github.com/alicebob/gopher-json/LICENSE
6 changes: 5 additions & 1 deletion client/tenant/tenant.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Northern.tech AS
// Copyright 2021 Northern.tech AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -11,9 +11,11 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package tenant

import (
"github.com/mendersoftware/go-lib-micro/addons"
"github.com/mendersoftware/go-lib-micro/ratelimits"
)

Expand All @@ -24,6 +26,8 @@ type Tenant struct {
Status string `json:"status"`
Plan string `json:"plan"`
ApiLimits TenantApiLimits `json:"api_limits"`

Addons []addons.Addon `json:"addons"`
}

type TenantApiLimits struct {
Expand Down
10 changes: 5 additions & 5 deletions devauth/devauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"time"

"github.com/Azure/go-autorest/autorest/to"
"github.com/mendersoftware/go-lib-micro/addons"
"github.com/mendersoftware/go-lib-micro/apiclient"
ctxhttpheader "github.com/mendersoftware/go-lib-micro/context/httpheader"
"github.com/mendersoftware/go-lib-micro/identity"
Expand Down Expand Up @@ -427,13 +428,12 @@ func (d *DevAuth) SubmitAuthRequest(ctx context.Context, r *model.AuthReq) (stri
}}

if d.verifyTenant {
ident := identity.FromContext(ctx)
if ident != nil && ident.Tenant != "" {
token.Claims.Tenant = ident.Tenant
token.Claims.Plan = tenant.Plan
}
token.Claims.Tenant = tenant.ID
token.Claims.Plan = tenant.Plan
token.Claims.Addons = tenant.Addons
} else {
token.Claims.Plan = plan.PlanEnterprise
token.Addons = addons.AllAddonsEnabled
}

// sign and encode as JWT
Expand Down
5 changes: 3 additions & 2 deletions devauth/devauth_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Northern.tech AS
// Copyright 2021 Northern.tech AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package devauth

import (
Expand Down Expand Up @@ -630,7 +631,7 @@ func TestDevAuthSubmitAuthRequest(t *testing.T) {
mtesting.ContextMatcher(),
tc.inReq.TenantToken).
Return(
&tenant.Tenant{},
&tenant.Tenant{ID: "foobar"},
tc.tenantVerificationErr)
}
if tc.config.DefaultTenantToken != "" {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/go-redis/redis/v8 v8.5.0
github.com/gomodule/redigo v1.8.2 // indirect
github.com/mendersoftware/go-lib-micro v0.0.0-20201013131806-cf1f6a851bcb
github.com/mendersoftware/go-lib-micro v0.0.0-20210311084510-06d0c5918746
github.com/pkg/errors v0.9.1
github.com/satori/go.uuid v1.2.0
github.com/stretchr/testify v1.7.0
Expand Down

0 comments on commit 74362f9

Please sign in to comment.