NOISSUE-Update invalid secret error handling (#1856)

* update invalid secret error handling

Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com>

* update secret error naming

Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com>

* update secretError naming

Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com>

* fix comment

Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com>

* add empty space in comment

Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com>

---------

Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com>
This commit is contained in:
Ian Ngethe Muchiri 2023-07-13 00:02:59 +03:00 committed by GitHub
parent 1192325a2e
commit 031e0a62f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -42,4 +42,7 @@ var (
// ErrScanMetadata indicates problem with metadata in db.
ErrScanMetadata = New("failed to scan metadata in db")
// ErrWrongSecret indicates a wrong secret was provided.
ErrWrongSecret = New("wrong secret")
)

View File

@ -111,7 +111,7 @@ func (svc service) IssueToken(ctx context.Context, identity, secret string) (jwt
return jwt.Token{}, errors.Wrap(errors.ErrAuthentication, err)
}
if err := svc.hasher.Compare(secret, dbUser.Credentials.Secret); err != nil {
return jwt.Token{}, errors.Wrap(errors.ErrAuthentication, err)
return jwt.Token{}, errors.Wrap(errors.ErrWrongSecret, err)
}
claims := jwt.Claims{
@ -315,7 +315,7 @@ func (svc service) UpdateClientSecret(ctx context.Context, token, oldSecret, new
return mfclients.Client{}, err
}
if _, err := svc.IssueToken(ctx, dbClient.Credentials.Identity, oldSecret); err != nil {
return mfclients.Client{}, errors.ErrAuthentication
return mfclients.Client{}, err
}
newSecret, err = svc.hasher.Hash(newSecret)
if err != nil {