RIPAGlobal / scimitar

A SCIM v2 API endpoint implementation
MIT License
61 stars 43 forks source link

Supports Google Workspace #142

Open kwent opened 1 month ago

kwent commented 1 month ago

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
jeremybdk commented 3 days ago

Hey, Thanks for the patch, I was wondering if you had a guide/doc to share on how to use SCIM with google workspace. From my understanding it was only by creating a custom app with validation from Google.

Is this still the case? I would love to use this :)