Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: nyagamunene <[email protected]>
  • Loading branch information
nyagamunene committed Nov 10, 2024
1 parent 8e316f0 commit f204e8c
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 46 deletions.
6 changes: 3 additions & 3 deletions auth/hasher/hasher.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
"time"

"github.com/absmach/magistrala/pat"
"github.com/absmach/magistrala/auth"
"github.com/absmach/magistrala/pkg/errors"
"golang.org/x/crypto/scrypt"
)
Expand All @@ -24,12 +24,12 @@ var (
errDecode = errors.New("failed to decode")
)

var _ pat.Hasher = (*bcryptHasher)(nil)
var _ auth.Hasher = (*bcryptHasher)(nil)

type bcryptHasher struct{}

// New instantiates a bcrypt-based hasher implementation.
func New() pat.Hasher {
func New() auth.Hasher {
return &bcryptHasher{}
}

Expand Down
22 changes: 11 additions & 11 deletions auth/mocks/pats.go

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

22 changes: 11 additions & 11 deletions auth/mocks/service.go

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

27 changes: 13 additions & 14 deletions auth/pat.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"fmt"
"time"

"github.com/absmach/magistrala/pkg/authn"
"github.com/absmach/magistrala/pkg/errors"
)

Expand Down Expand Up @@ -715,41 +714,41 @@ func (pat PAT) Expired() bool {
}

// PATS specifies function which are required for Personal access Token implementation.
//go:generate mockery --name Service --output=./mocks --filename pats.go --quiet --note "Copyright (c) Abstract Machines"
//go:generate mockery --name PATS --output=./mocks --filename pats.go --quiet --note "Copyright (c) Abstract Machines"

type Service interface {
type PATS interface {
// Create function creates new PAT for given valid inputs.
CreatePAT(ctx context.Context, session authn.Session, name, description string, duration time.Duration, scope Scope) (PAT, error)
CreatePAT(ctx context.Context, token, name, description string, duration time.Duration, scope Scope) (PAT, error)

// UpdateName function updates the name for the given PAT ID.
UpdatePATName(ctx context.Context, session authn.Session, patID, name string) (PAT, error)
UpdatePATName(ctx context.Context, token, patID, name string) (PAT, error)

// UpdateDescription function updates the description for the given PAT ID.
UpdatePATDescription(ctx context.Context, session authn.Session, patID, description string) (PAT, error)
UpdatePATDescription(ctx context.Context, token, patID, description string) (PAT, error)

// Retrieve function retrieves the PAT for given ID.
RetrievePAT(ctx context.Context, userID, patID string) (PAT, error)
RetrievePAT(ctx context.Context, userID string, patID string) (PAT, error)

// List function lists all the PATs for the user.
ListPATS(ctx context.Context, session authn.Session, pm PATSPageMeta) (PATSPage, error)
ListPATS(ctx context.Context, token string, pm PATSPageMeta) (PATSPage, error)

// Delete function deletes the PAT for given ID.
DeletePAT(ctx context.Context, session authn.Session, patID string) error
DeletePAT(ctx context.Context, token, patID string) error

// ResetSecret function reset the secret and creates new secret for the given ID.
ResetPATSecret(ctx context.Context, session authn.Session, patID string, duration time.Duration) (PAT, error)
ResetPATSecret(ctx context.Context, token, patID string, duration time.Duration) (PAT, error)

// RevokeSecret function revokes the secret for the given ID.
RevokePATSecret(ctx context.Context, session authn.Session, patID string) error
RevokePATSecret(ctx context.Context, token, patID string) error

// AddScope function adds a new scope entry.
AddPATScopeEntry(ctx context.Context, session authn.Session, patID string, platformEntityType PlatformEntityType, optionalDomainID string, optionalDomainEntityType DomainEntityType, operation OperationType, entityIDs ...string) (Scope, error)
AddPATScopeEntry(ctx context.Context, token, patID string, platformEntityType PlatformEntityType, optionalDomainID string, optionalDomainEntityType DomainEntityType, operation OperationType, entityIDs ...string) (Scope, error)

// RemoveScope function removes a scope entry.
RemovePATScopeEntry(ctx context.Context, session authn.Session, patID string, platformEntityType PlatformEntityType, optionalDomainID string, optionalDomainEntityType DomainEntityType, operation OperationType, entityIDs ...string) (Scope, error)
RemovePATScopeEntry(ctx context.Context, token, patID string, platformEntityType PlatformEntityType, optionalDomainID string, optionalDomainEntityType DomainEntityType, operation OperationType, entityIDs ...string) (Scope, error)

// ClearAllScope function removes all scope entry.
ClearPATAllScopeEntry(ctx context.Context, session authn.Session, patID string) error
ClearPATAllScopeEntry(ctx context.Context, token, patID string) error

// IdentifyPAT function will valid the secret.
IdentifyPAT(ctx context.Context, paToken string) (PAT, error)
Expand Down
10 changes: 4 additions & 6 deletions internal/grpc/auth/v1/auth.pb.go

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

18 changes: 18 additions & 0 deletions pkg/authz/mocks/authz.go

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

1 change: 0 additions & 1 deletion things/middleware/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/absmach/magistrala/pkg/authn"
"github.com/absmach/magistrala/pkg/authz"
mgauthz "github.com/absmach/magistrala/pkg/authz"
"github.com/absmach/magistrala/pkg/clients"
"github.com/absmach/magistrala/pkg/errors"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
"github.com/absmach/magistrala/pkg/policies"
Expand Down

0 comments on commit f204e8c

Please sign in to comment.