diff --git a/app/controllers/concerns/scim_rails/exception_handler.rb b/app/controllers/concerns/scim_rails/exception_handler.rb index 5661288..eff4a26 100644 --- a/app/controllers/concerns/scim_rails/exception_handler.rb +++ b/app/controllers/concerns/scim_rails/exception_handler.rb @@ -10,19 +10,48 @@ module ScimRails included do rescue_from ScimRails::ExceptionHandler::InvalidCredentials do - json_response({ message: "Invalid credentials" }, :unauthorized) + json_response( + { + schemas: ["urn:ietf:params:scim:api:messages:2.0:Error"], + detail: "Authorization failure. The authorization header is invalid or missing.", + status: "401" + }, + :unauthorized + ) end rescue_from ScimRails::ExceptionHandler::MissingCredentials do - json_response({ message: "Missing credentials" }, :unauthorized) + json_response( + { + schemas: ["urn:ietf:params:scim:api:messages:2.0:Error"], + detail: "Authorization failure. The authorization header is invalid or missing.", + status: "401" + }, + :unauthorized + ) end rescue_from ActiveRecord::RecordNotFound do |e| - json_response({ message: e.message }, :not_found) + json_response( + { + schemas: ["urn:ietf:params:scim:api:messages:2.0:Error"], + detail: "Resource #{e.id} not found.", + status: "404" + }, + :not_found + ) end rescue_from ActiveRecord::RecordInvalid do |e| - json_response({ message: e.message }, :unprocessable_entity) + json_response( + { + schemas: ["urn:ietf:params:scim:api:messages:2.0:Error"], + scimType: "invalidValue", + detail: e.message, + status: "400" + }, + :unprocessable_entity + ) end end end -- libgit2 0.21.0