SMQ-3415 - Return correct error in auth gRPC response (#3416)

Signed-off-by: Arvindh <arvindh91@gmail.com>
This commit is contained in:
Arvindh
2026-04-07 14:07:55 +05:30
committed by GitHub
parent 69d02ed58e
commit 6c7e5d893d
3 changed files with 5 additions and 7 deletions
+1 -1
View File
@@ -331,7 +331,7 @@ func (svc service) invitationKey(ctx context.Context, key Key) (Token, error) {
func (svc service) refreshKey(ctx context.Context, token string, key Key) (Token, error) {
k, err := svc.tokenizer.Parse(ctx, token)
if err != nil {
return Token{}, errors.Wrap(errRetrieve, err)
return Token{}, errors.Wrap(svcerr.ErrAuthentication, err)
}
if k.Type != RefreshKey {
return Token{}, errIssueUser
+2 -3
View File
@@ -9,7 +9,6 @@ import (
"github.com/absmach/magistrala/auth"
smqjwt "github.com/absmach/magistrala/auth/tokenizer/util"
"github.com/absmach/magistrala/pkg/errors"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
"github.com/lestrrat-go/jwx/v2/jwa"
"github.com/lestrrat-go/jwx/v2/jwt"
)
@@ -61,9 +60,9 @@ func (tok *tokenizer) Parse(ctx context.Context, tokenString string) (auth.Key,
)
if err != nil {
if errors.Contains(err, smqjwt.ErrJWTExpiryKey) {
return auth.Key{}, errors.Wrap(svcerr.ErrAuthentication, auth.ErrExpiry)
return auth.Key{}, auth.ErrExpiry
}
return auth.Key{}, errors.Wrap(svcerr.ErrAuthentication, err)
return auth.Key{}, err
}
if tkn.Issuer() != smqjwt.IssuerName {