Skip to content

Commit

Permalink
chore(deviceauth): moving tenantadm client to pkg
Browse files Browse the repository at this point in the history
Changelog: None
Ticket: MEN-7715
Signed-off-by: Peter Grzybowski <peter@northern.tech>
  • Loading branch information
merlin-northern committed Nov 7, 2024
1 parent 22358d0 commit 53ed43d
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Northern.tech AS
// Copyright 2024 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 Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Northern.tech AS
// Copyright 2024 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 Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Northern.tech AS
// Copyright 2024 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 Down
2 changes: 1 addition & 1 deletion backend/services/deviceauth/api/http/api_devauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ import (
"github.com/mendersoftware/mender-server/pkg/requestid"
"github.com/mendersoftware/mender-server/pkg/rest_utils"

"github.com/mendersoftware/mender-server/pkg/tenant"
mt "github.com/mendersoftware/mender-server/pkg/testing"

"github.com/mendersoftware/mender-server/services/deviceauth/cache"
"github.com/mendersoftware/mender-server/services/deviceauth/client/tenant"
"github.com/mendersoftware/mender-server/services/deviceauth/devauth"
"github.com/mendersoftware/mender-server/services/deviceauth/devauth/mocks"
"github.com/mendersoftware/mender-server/services/deviceauth/jwt"
Expand Down
2 changes: 1 addition & 1 deletion backend/services/deviceauth/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
"github.com/mendersoftware/mender-server/pkg/log"
"github.com/mendersoftware/mender-server/pkg/mongo/migrate"
mstore "github.com/mendersoftware/mender-server/pkg/store"
"github.com/mendersoftware/mender-server/pkg/tenant"

cinv "github.com/mendersoftware/mender-server/services/deviceauth/client/inventory"
"github.com/mendersoftware/mender-server/services/deviceauth/client/orchestrator"
"github.com/mendersoftware/mender-server/services/deviceauth/client/tenant"
dconfig "github.com/mendersoftware/mender-server/services/deviceauth/config"
"github.com/mendersoftware/mender-server/services/deviceauth/model"
"github.com/mendersoftware/mender-server/services/deviceauth/store"
Expand Down
4 changes: 2 additions & 2 deletions backend/services/deviceauth/cmd/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import (
"github.com/mendersoftware/mender-server/pkg/mongo/migrate"
"github.com/mendersoftware/mender-server/pkg/mongo/oid"
ctxstore "github.com/mendersoftware/mender-server/pkg/store"
"github.com/mendersoftware/mender-server/pkg/tenant"
mtenant "github.com/mendersoftware/mender-server/pkg/tenant/mocks"

minv "github.com/mendersoftware/mender-server/services/deviceauth/client/inventory/mocks"
"github.com/mendersoftware/mender-server/services/deviceauth/client/orchestrator"
mwflows "github.com/mendersoftware/mender-server/services/deviceauth/client/orchestrator/mocks"
"github.com/mendersoftware/mender-server/services/deviceauth/client/tenant"
mtenant "github.com/mendersoftware/mender-server/services/deviceauth/client/tenant/mocks"
"github.com/mendersoftware/mender-server/services/deviceauth/store"

//dconfig "github.com/mendersoftware/mender-server/services/deviceauth/config"
Expand Down
18 changes: 9 additions & 9 deletions backend/services/deviceauth/devauth/devauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ import (
"github.com/mendersoftware/mender-server/pkg/plan"
"github.com/mendersoftware/mender-server/pkg/ratelimits"
"github.com/mendersoftware/mender-server/pkg/requestid"
tenant2 "github.com/mendersoftware/mender-server/pkg/tenant"

"github.com/mendersoftware/mender-server/services/deviceauth/access"
"github.com/mendersoftware/mender-server/services/deviceauth/cache"
"github.com/mendersoftware/mender-server/services/deviceauth/client/inventory"
"github.com/mendersoftware/mender-server/services/deviceauth/client/orchestrator"
"github.com/mendersoftware/mender-server/services/deviceauth/client/tenant"
"github.com/mendersoftware/mender-server/services/deviceauth/jwt"
"github.com/mendersoftware/mender-server/services/deviceauth/model"
"github.com/mendersoftware/mender-server/services/deviceauth/store"
Expand Down Expand Up @@ -118,7 +118,7 @@ type DevAuth struct {
db store.DataStore
invClient inventory.Client
cOrch orchestrator.ClientRunner
cTenant tenant.ClientRunner
cTenant tenant2.ClientRunner
jwt jwt.Handler
jwtFallback jwt.Handler
verifyTenant bool
Expand Down Expand Up @@ -282,11 +282,11 @@ func (d *DevAuth) signToken(ctx context.Context) jwt.SignFunc {
}
}

func (d *DevAuth) doVerifyTenant(ctx context.Context, token string) (*tenant.Tenant, error) {
func (d *DevAuth) doVerifyTenant(ctx context.Context, token string) (*tenant2.Tenant, error) {
t, err := d.cTenant.VerifyToken(ctx, token)

if err != nil {
if tenant.IsErrTokenVerificationFailed(err) {
if tenant2.IsErrTokenVerificationFailed(err) {
return nil, MakeErrDevAuthUnauthorized(err)
}

Expand All @@ -300,14 +300,14 @@ func (d *DevAuth) getTenantWithDefault(
ctx context.Context,
tenantToken,
defaultToken string,
) (context.Context, *tenant.Tenant, error) {
) (context.Context, *tenant2.Tenant, error) {
l := log.FromContext(ctx)

if tenantToken == "" && defaultToken == "" {
return nil, nil, MakeErrDevAuthUnauthorized(errors.New("tenant token missing"))
}

var t *tenant.Tenant
var t *tenant2.Tenant
var err error

// try the provided token
Expand All @@ -331,7 +331,7 @@ func (d *DevAuth) getTenantWithDefault(

// none of the tokens worked
if err != nil {
if tenant.IsErrTokenVerificationFailed(err) {
if tenant2.IsErrTokenVerificationFailed(err) {
return ctx, nil, MakeErrDevAuthUnauthorized(err)
}
return ctx, nil, err
Expand All @@ -348,7 +348,7 @@ func (d *DevAuth) getTenantWithDefault(
func (d *DevAuth) SubmitAuthRequest(ctx context.Context, r *model.AuthReq) (string, error) {
l := log.FromContext(ctx)

var tenant *tenant.Tenant
var tenant *tenant2.Tenant
var err error

if d.verifyTenant {
Expand Down Expand Up @@ -1544,7 +1544,7 @@ func (d *DevAuth) WithJWTFallbackHandler(handler jwt.Handler) *DevAuth {
// WithTenantVerification will force verification of tenant token with tenant
// administrator when processing device authentication requests. Returns an
// updated devauth.
func (d *DevAuth) WithTenantVerification(c tenant.ClientRunner) *DevAuth {
func (d *DevAuth) WithTenantVerification(c tenant2.ClientRunner) *DevAuth {
d.cTenant = c
d.verifyTenant = true
return d
Expand Down
4 changes: 2 additions & 2 deletions backend/services/deviceauth/devauth/devauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
"github.com/mendersoftware/mender-server/pkg/identity"
"github.com/mendersoftware/mender-server/pkg/mongo/oid"
"github.com/mendersoftware/mender-server/pkg/ratelimits"
"github.com/mendersoftware/mender-server/pkg/tenant"
mtenant "github.com/mendersoftware/mender-server/pkg/tenant/mocks"

"github.com/pkg/errors"

Expand All @@ -36,8 +38,6 @@ import (
minv "github.com/mendersoftware/mender-server/services/deviceauth/client/inventory/mocks"
"github.com/mendersoftware/mender-server/services/deviceauth/client/orchestrator"
morchestrator "github.com/mendersoftware/mender-server/services/deviceauth/client/orchestrator/mocks"
"github.com/mendersoftware/mender-server/services/deviceauth/client/tenant"
mtenant "github.com/mendersoftware/mender-server/services/deviceauth/client/tenant/mocks"
"github.com/mendersoftware/mender-server/services/deviceauth/jwt"
mjwt "github.com/mendersoftware/mender-server/services/deviceauth/jwt/mocks"
"github.com/mendersoftware/mender-server/services/deviceauth/model"
Expand Down
2 changes: 1 addition & 1 deletion backend/services/deviceauth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import (

"github.com/mendersoftware/mender-server/pkg/config"
"github.com/mendersoftware/mender-server/pkg/log"
"github.com/mendersoftware/mender-server/pkg/tenant"
"github.com/mendersoftware/mender-server/pkg/version"

cinv "github.com/mendersoftware/mender-server/services/deviceauth/client/inventory"
"github.com/mendersoftware/mender-server/services/deviceauth/client/orchestrator"
"github.com/mendersoftware/mender-server/services/deviceauth/client/tenant"
"github.com/mendersoftware/mender-server/services/deviceauth/cmd"
dconfig "github.com/mendersoftware/mender-server/services/deviceauth/config"
"github.com/mendersoftware/mender-server/services/deviceauth/store/mongo"
Expand Down
2 changes: 1 addition & 1 deletion backend/services/deviceauth/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import (

"github.com/mendersoftware/mender-server/pkg/config"
"github.com/mendersoftware/mender-server/pkg/log"
"github.com/mendersoftware/mender-server/pkg/tenant"

api_http "github.com/mendersoftware/mender-server/services/deviceauth/api/http"
"github.com/mendersoftware/mender-server/services/deviceauth/cache"
"github.com/mendersoftware/mender-server/services/deviceauth/client/orchestrator"
"github.com/mendersoftware/mender-server/services/deviceauth/client/tenant"
dconfig "github.com/mendersoftware/mender-server/services/deviceauth/config"
"github.com/mendersoftware/mender-server/services/deviceauth/devauth"
"github.com/mendersoftware/mender-server/services/deviceauth/jwt"
Expand Down

0 comments on commit 53ed43d

Please sign in to comment.