Skip to content

Commit

Permalink
fix(dump) address free mode workaround regression (#335)
Browse files Browse the repository at this point in the history
573de55 did not properly handle _successful_ mTLS responses, as the nil
error would not coerce to a Kong API error. Move the workaround into the
error handling block to ensure that there is in fact an error response
before checking its status.
  • Loading branch information
Travis Raines committed Apr 22, 2021
1 parent 3dc56be commit 6df7756
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,18 +660,20 @@ func GetAllMTLSAuths(ctx context.Context,
if kong.IsNotFoundErr(err) {
return mtlsAuths, nil
}
// TODO figure out a better way to handle unauthorized endpoints
// per https://github.com/Kong/deck/issues/274 we can't dump these resources
// from an Enterprise instance running in free mode, and the 403 results in a
// fatal error when running "deck dump". We don't want to just treat 403s the
// same as 404s because Kong also uses them to indicate missing RBAC permissions,
// but this is currently necessary for compatibility. We need a better approach
// before adding other Enterprise resources that decK handles by default (versus,
// for example, RBAC roles, which require the --rbac-resources-only flag).
if err.(*kong.APIError).Code() == 403 {
return mtlsAuths, nil
}
if err != nil {
// TODO figure out a better way to handle unauthorized endpoints
// per https://github.com/Kong/deck/issues/274 we can't dump these resources
// from an Enterprise instance running in free mode, and the 403 results in a
// fatal error when running "deck dump". We don't want to just treat 403s the
// same as 404s because Kong also uses them to indicate missing RBAC permissions,
// but this is currently necessary for compatibility. We need a better approach
// before adding other Enterprise resources that decK handles by default (versus,
// for example, RBAC roles, which require the --rbac-resources-only flag).
if kongErr, ok := err.(*kong.APIError); ok {
if kongErr.Code() == 403 {
return mtlsAuths, nil
}
}
return nil, err
}
if err := ctx.Err(); err != nil {
Expand Down

0 comments on commit 6df7756

Please sign in to comment.