98bf463a65
This change makes it so that if a lease is revoked through user action, we set the expiration time to now and update pending, just as we do with tokens. This allows the normal retry logic to apply in these cases as well, instead of just erroring out immediately. The idea being that once you tell Vault to revoke something it should keep doing its darndest to actually make that happen.
75 lines
1.8 KiB
Go
75 lines
1.8 KiB
Go
package logical
|
|
|
|
import "errors"
|
|
|
|
var (
|
|
// ErrUnsupportedOperation is returned if the operation is not supported
|
|
// by the logical backend.
|
|
ErrUnsupportedOperation = errors.New("unsupported operation")
|
|
|
|
// ErrUnsupportedPath is returned if the path is not supported
|
|
// by the logical backend.
|
|
ErrUnsupportedPath = errors.New("unsupported path")
|
|
|
|
// ErrInvalidRequest is returned if the request is invalid
|
|
ErrInvalidRequest = errors.New("invalid request")
|
|
|
|
// ErrPermissionDenied is returned if the client is not authorized
|
|
ErrPermissionDenied = errors.New("permission denied")
|
|
|
|
// ErrMultiAuthzPending is returned if the the request needs more
|
|
// authorizations
|
|
ErrMultiAuthzPending = errors.New("request needs further approval")
|
|
)
|
|
|
|
type HTTPCodedError interface {
|
|
Error() string
|
|
Code() int
|
|
}
|
|
|
|
func CodedError(status int, msg string) HTTPCodedError {
|
|
return &codedError{
|
|
Status: status,
|
|
Message: msg,
|
|
}
|
|
}
|
|
|
|
var _ HTTPCodedError = (*codedError)(nil)
|
|
|
|
type codedError struct {
|
|
Status int
|
|
Message string
|
|
}
|
|
|
|
func (e *codedError) Error() string {
|
|
return e.Message
|
|
}
|
|
|
|
func (e *codedError) Code() int {
|
|
return e.Status
|
|
}
|
|
|
|
// Struct to identify user input errors. This is helpful in responding the
|
|
// appropriate status codes to clients from the HTTP endpoints.
|
|
type StatusBadRequest struct {
|
|
Err string
|
|
}
|
|
|
|
// Implementing error interface
|
|
func (s *StatusBadRequest) Error() string {
|
|
return s.Err
|
|
}
|
|
|
|
// This is a new type declared to not cause potential compatibility problems if
|
|
// the logic around the CodedError changes; in particular for logical request
|
|
// paths it is basically ignored, and changing that behavior might cause
|
|
// unforseen issues.
|
|
type ReplicationCodedError struct {
|
|
Msg string
|
|
Code int
|
|
}
|
|
|
|
func (r *ReplicationCodedError) Error() string {
|
|
return r.Msg
|
|
}
|