* refactor (controller): Use a grpc server for the grpc-gateway This starts a grpc server for the grpc-gateway. The new gateway server uses an in-memory listener which also supports "dialing", so the http proxy can connect to the in-memory listener. This change allows us to use all grpc server features and was in part motivated by a need for an interceptor of inbound requests. With that said, having a "proper" grpc server for the gateway will provide a lot more flexibility and capabilities moving forward. The request context will still be verified via middleware in the http proxy (see wrapHandlerWithCommonFuncs). This verified context will be serialized into a protobuf and sent along to the grpc-gateway via metadata where an interceptor will add the verified request info to the request's context (see requestCtxInterceptor). The interceptor will verify the serialized request info via a shared ticket with it's companion in-memory http proxy. FYI: the ticket is simply random base62 string (see db.NewPrivateId). This change also necessitated a minor change to services. We need to return an empty response instead of nil, nil when there are no errors and the response is empty. * refactor (handlers): Rename gRPC Gateway filter Originally, this was called an OutgoingInterceptor, which is an unfortunate name since it's not an interceptor. Now that we're refactoring the gateway stuff and have proper interceptors, renaming this should remove ambiguity * refactor: Rework how 204 with empty msg is handled Recent changes to grpc gateway has necessitated a change to how 204s are handled by the gateway * tests (bats): Check status codes for delete operations
240 lines
5.1 KiB
Go
240 lines
5.1 KiB
Go
package errors
|
|
|
|
// Info contains details of the specific error code
|
|
type Info struct {
|
|
// Kind specifies the kind of error (unknown, parameter, integrity, etc).
|
|
Kind Kind
|
|
|
|
// Message provides a default message for the error code
|
|
Message string
|
|
}
|
|
|
|
// errorCodeInfo provides a map of unique Codes (IDs) to their
|
|
// corresponding Kind and a default Message.
|
|
var errorCodeInfo = map[Code]Info{
|
|
Unknown: {
|
|
Message: "unknown",
|
|
Kind: Other,
|
|
},
|
|
InvalidParameter: {
|
|
Message: "invalid parameter",
|
|
Kind: Parameter,
|
|
},
|
|
InvalidAddress: {
|
|
Message: "invalid address",
|
|
Kind: Parameter,
|
|
},
|
|
InvalidPublicId: {
|
|
Message: "invalid public id",
|
|
Kind: Parameter,
|
|
},
|
|
InvalidFieldMask: {
|
|
Message: "invalid field mask",
|
|
Kind: Parameter,
|
|
},
|
|
EmptyFieldMask: {
|
|
Message: "empty field mask",
|
|
Kind: Parameter,
|
|
},
|
|
KeyNotFound: {
|
|
Message: "key/version not found",
|
|
Kind: Integrity,
|
|
},
|
|
TicketAlreadyRedeemed: {
|
|
Message: "ticket already redeemed",
|
|
Kind: Integrity,
|
|
},
|
|
TicketNotFound: {
|
|
Message: "ticket not found",
|
|
Kind: Integrity,
|
|
},
|
|
Io: {
|
|
Message: "error during io operation",
|
|
Kind: Integrity,
|
|
},
|
|
InvalidTimeStamp: {
|
|
Message: "invalid time stamp",
|
|
Kind: Integrity,
|
|
},
|
|
SessionNotFound: {
|
|
Message: "session not found",
|
|
Kind: Integrity,
|
|
},
|
|
InvalidSessionState: {
|
|
Message: "session state was not valid for the requested operation",
|
|
Kind: Integrity,
|
|
},
|
|
TokenMismatch: {
|
|
Message: "token mismatch",
|
|
Kind: Integrity,
|
|
},
|
|
TooShort: {
|
|
Message: "too short",
|
|
Kind: Integrity,
|
|
},
|
|
AuthMethodInactive: {
|
|
Message: "authentication method is inactive",
|
|
Kind: State,
|
|
},
|
|
AuthAttemptExpired: {
|
|
Message: "authentication attempt has expired",
|
|
Kind: State,
|
|
},
|
|
AccountAlreadyAssociated: {
|
|
Message: "account already associated with another user",
|
|
Kind: Parameter,
|
|
},
|
|
InvalidJobRunState: {
|
|
Message: "job run is already in a final run state",
|
|
Kind: Integrity,
|
|
},
|
|
JobAlreadyRunning: {
|
|
Message: "job already running",
|
|
Kind: State,
|
|
},
|
|
SubtypeAlreadyRegistered: {
|
|
Message: "subtype already registered",
|
|
Kind: Parameter,
|
|
},
|
|
InvalidDynamicCredential: {
|
|
Message: "dynamic credential for session is in an invalid state",
|
|
Kind: Integrity,
|
|
},
|
|
PasswordTooShort: {
|
|
Message: "too short",
|
|
Kind: Password,
|
|
},
|
|
PasswordUnsupportedConfiguration: {
|
|
Message: "unable to support the password config type",
|
|
Kind: Password,
|
|
},
|
|
PasswordInvalidConfiguration: {
|
|
Message: "invalid parameters in password configuration",
|
|
Kind: Password,
|
|
},
|
|
PasswordsEqual: {
|
|
Message: "old and new password are equal",
|
|
Kind: Password,
|
|
},
|
|
Encrypt: {
|
|
Message: "error occurred during encrypt",
|
|
Kind: Encryption,
|
|
},
|
|
Decrypt: {
|
|
Message: "error occurred during decrypt",
|
|
Kind: Encryption,
|
|
},
|
|
Encode: {
|
|
Message: "error occurred during encode",
|
|
Kind: Encoding,
|
|
},
|
|
Decode: {
|
|
Message: "error occurred during decode",
|
|
Kind: Encoding,
|
|
},
|
|
GenKey: {
|
|
Message: "error occurred during key generation",
|
|
Kind: Encryption,
|
|
},
|
|
GenCert: {
|
|
Message: "error occurred during certification generation",
|
|
Kind: Encryption,
|
|
},
|
|
Internal: {
|
|
Message: "internal error",
|
|
Kind: Other,
|
|
},
|
|
Forbidden: {
|
|
Message: "forbidden",
|
|
Kind: Other,
|
|
},
|
|
Unauthorized: {
|
|
Message: "unauthorized",
|
|
Kind: Other,
|
|
},
|
|
CheckConstraint: {
|
|
Message: "constraint check failed",
|
|
Kind: Integrity,
|
|
},
|
|
NotNull: {
|
|
Message: "must not be empty (null) violation",
|
|
Kind: Integrity,
|
|
},
|
|
NotUnique: {
|
|
Message: "must be unique violation",
|
|
Kind: Integrity,
|
|
},
|
|
NotSpecificIntegrity: {
|
|
Message: "Integrity violation without specific details",
|
|
Kind: Integrity,
|
|
},
|
|
MissingTable: {
|
|
Message: "missing table",
|
|
Kind: Integrity,
|
|
},
|
|
ColumnNotFound: {
|
|
Message: "column not found",
|
|
Kind: Integrity,
|
|
},
|
|
RecordNotFound: {
|
|
Message: "record not found",
|
|
Kind: Search,
|
|
},
|
|
MultipleRecords: {
|
|
Message: "multiple records",
|
|
Kind: Search,
|
|
},
|
|
Exception: {
|
|
Message: "db exception",
|
|
Kind: Integrity,
|
|
},
|
|
VersionMismatch: {
|
|
Message: "version mismatch",
|
|
Kind: Integrity,
|
|
},
|
|
MaxRetries: {
|
|
Message: "too many retries",
|
|
Kind: Transaction,
|
|
},
|
|
MigrationIntegrity: {
|
|
Message: "migration integrity",
|
|
Kind: Integrity,
|
|
},
|
|
MigrationLock: {
|
|
Message: "bad db lock",
|
|
Kind: Integrity,
|
|
},
|
|
Unavailable: {
|
|
Message: "external system unavailable",
|
|
Kind: External,
|
|
},
|
|
VaultTokenNotOrphan: {
|
|
Message: "vault token is not an orphan token",
|
|
Kind: VaultToken,
|
|
},
|
|
VaultTokenNotPeriodic: {
|
|
Message: "vault token is not a periodic token",
|
|
Kind: VaultToken,
|
|
},
|
|
VaultTokenNotRenewable: {
|
|
Message: "vault token is not renewable",
|
|
Kind: VaultToken,
|
|
},
|
|
VaultTokenMissingCapabilities: {
|
|
Message: "vault token is missing capabilities",
|
|
Kind: VaultToken,
|
|
},
|
|
VaultCredentialRequest: {
|
|
Message: "request for a new credential from vault failed",
|
|
Kind: External,
|
|
},
|
|
OidcProviderCallbackError: {
|
|
Message: "oidc provider callback error",
|
|
Kind: External,
|
|
},
|
|
GracefullyAborted: {
|
|
Message: "purposefully aborted without error",
|
|
Kind: Other,
|
|
},
|
|
}
|