Commit 62f7611
Changed files (4)
app
controllers
scim
app/controllers/scim/controller.rb
@@ -7,12 +7,13 @@ module Scim
before_action :ensure_correct_content_type!
before_action :authenticate!
helper_method :current_user
- rescue_from ActiveRecord::RecordNotFound, with: :not_found
- rescue_from ActiveRecord::RecordInvalid do |error|
- @error = error
- @model = error.record
- render "record_invalid", status: :bad_request
+ rescue_from StandardError do |error|
+ Rails.logger.error(error)
+ render "server_error", status: :server_error
end
+ rescue_from ActiveRecord::RecordInvalid, with: :record_invalid
+ rescue_from ActiveModel::ValidationError, with: :record_invalid
+ rescue_from ActiveRecord::RecordNotFound, with: :not_found
def current_user
Current.user
@@ -32,6 +33,12 @@ module Scim
}.to_json, status: :not_found
end
+ def record_invalid(error)
+ @error = error
+ @model = error.model
+ render "record_invalid", status: :bad_request
+ end
+
private
def authenticate!
app/views/scim/forbidden.scim.jbuilder
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+json.schemas ["urn:ietf:params:scim:api:messages:2.0:Error"]
+json.detail @error.message
+json.status "403"
app/views/scim/server_error.scim.jbuilder
@@ -0,0 +1,6 @@
+# frozen_string_literal: true
+
+json.schemas ["urn:ietf:params:scim:api:messages:2.0:Error"]
+json.scimType ""
+json.detail ""
+json.status "500"
app/views/scim/unsupported_media_type.scim.jbuilder
@@ -0,0 +1,6 @@
+# frozen_string_literal: true
+
+json.schemas ["urn:ietf:params:scim:api:messages:2.0:Error"]
+json.scimType "invalidValue"
+json.detail 'Unsupported Content-Type: Use application/scim+json'
+json.status "415"