mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 20:27:32 +00:00
fix: check error before using token (#7664)
This commit is contained in:
@@ -110,15 +110,15 @@ func (repo *TokenVerifierRepo) verifyAccessTokenV1(ctx context.Context, tokenID,
|
|||||||
ctx, span := tracing.NewSpan(ctx)
|
ctx, span := tracing.NewSpan(ctx)
|
||||||
defer func() { span.EndWithError(err) }()
|
defer func() { span.EndWithError(err) }()
|
||||||
|
|
||||||
_, tokenSpan := tracing.NewNamedSpan(ctx, "token")
|
_, tokenSpan := tracing.NewNamedSpan(ctx, "tokenByID")
|
||||||
token, err := repo.tokenByID(ctx, tokenID, subject)
|
token, err := repo.tokenByID(ctx, tokenID, subject)
|
||||||
if token.Actor != nil {
|
|
||||||
return "", "", "", "", "", zerrors.ThrowPermissionDenied(nil, "APP-wai8O", "Errors.TokenExchange.Token.NotForAPI")
|
|
||||||
}
|
|
||||||
tokenSpan.EndWithError(err)
|
tokenSpan.EndWithError(err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", "", "", "", zerrors.ThrowUnauthenticated(err, "APP-BxUSiL", "invalid token")
|
return "", "", "", "", "", zerrors.ThrowUnauthenticated(err, "APP-BxUSiL", "invalid token")
|
||||||
}
|
}
|
||||||
|
if token.Actor != nil {
|
||||||
|
return "", "", "", "", "", zerrors.ThrowPermissionDenied(nil, "APP-wai8O", "Errors.TokenExchange.Token.NotForAPI")
|
||||||
|
}
|
||||||
if !token.Expiration.After(time.Now().UTC()) {
|
if !token.Expiration.After(time.Now().UTC()) {
|
||||||
return "", "", "", "", "", zerrors.ThrowUnauthenticated(err, "APP-k9KS0", "invalid token")
|
return "", "", "", "", "", zerrors.ThrowUnauthenticated(err, "APP-k9KS0", "invalid token")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user