Skip to content

Supports Google Workspace #142

@kwent

Description

@kwent

Supports Google Workspace

I know it's a bit out of scope and we should probably not support it but Google Workspace scim is using the wrong mime type ( application/json ) ( and not configurable ) and so library is returning 406.

For whoever ran into this issue in the future here is a monkeypatch below

Screenshot 2024-09-18 at 12 33 02 PM

# config/initializers/scimitar.rb
module Scimitar
  class ApplicationController
    private

    # Only difference with upstream is adding support for Google. request.user_agent == "Google-Auto-Provisioning"

    def require_scim
      scim_mime_type = Mime::Type.lookup_by_extension(:scim).to_s

      if request.media_type.nil? || request.media_type.empty?
        request.format = :scim
        request.headers["CONTENT_TYPE"] = scim_mime_type
      elsif request.user_agent == "Google-Auto-Provisioning"
        request.format = :scim
        request.headers["CONTENT_TYPE"] = scim_mime_type
      elsif request.media_type.downcase == scim_mime_type
        request.format = :scim
      elsif request.format == :scim
        request.headers["CONTENT_TYPE"] = scim_mime_type
      else
        handle_scim_error(ErrorResponse.new(status: 406, detail: "Only #{scim_mime_type} type is accepted."))
      end
    end
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions