0.01
No commit activity in last 3 years
No release in over 3 years
There's no general purpose SCIM SDK for Ruby on Rails. As a result, anyone implementing SCIM will need to take care of the SCIM schema and protocol, which may take a significant overhead compared the implementation of the actual APIs. This project aims to extract SCIM specifics as a rails engine that can be plugged into a Ruby on Rails project.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

= 10.0.2

Runtime

>= 1.10.4
>= 5.0
 Project Readme

ScimEngine

Build Status

Why ScimEngine Exists?

There's no general purpose SCIM SDK for Ruby on Rails. As a result, anyone implementing SCIM will need to take care of the SCIM schema and protocol, which may take a significant overhead compared the implementation of the actual APIs. This project aims to extract SCIM specifics as a rails engine that can be plugged into a Ruby on Rails project.

How to Use?

In your Gemfile, add:

gem 'scim_engine'

Mount this engine in config/routes:

namespace :scim do
  mount ScimEngine::Engine => '/'
end

This will provide you with routes for ServerProviderConfig, Schemas, and ResourceTypes under /scim prefix.

You can decide which SCIM resources you want to support, and provide routes / controllers accordingly. For example, to support the User resource type, add the following to your routes:

namespace :scim do
  get 'Users/:id', to: 'users#show', as: :user
  post 'Users', to: 'users#create'
  put 'Users/:id', to: 'users#update'
  delete 'Users/:id', to: 'users#destroy'
  mount ScimEngine::Engine => '/'
end

Add your controller:

# app/controllers/scim/users_controller.rb

module Scim

  # ScimEngine::ResourcesController uses a template method so that the
  # subclasses can provide the fillers with minimal effort solely focused on
  # application code leaving the SCIM protocol and schema specific code within the
  # engine.

  class UsersController < ScimEngine::ResourcesController

    def show
      super do |user_id|
        user = find_user(user_id)
        user.to_scim(location: url_for(action: :show, id: user_id))
      end
    end

    def create
      super(resource_type, &method(:save))
    end

    def update
      super(resource_type, &method(:save))
    end

    def destroy
      super do |user_id|
        user = find_user(user_id)
        user.delete
      end
    end


    protected

    def save(scim_user, is_create: false)
      #convert the ScimEngine::Resources::User to your application object
      #and save
    rescue ActiveRecord::RecordInvalid => exception
      # Map the enternal errors to a ScimEngine error
      raise ScimEngine::ResourceInvalidError.new()
    end

    # tell the base controller which resource you're handling
    def resource_type
      ScimEngine::Resources::User
    end

    def find_user(user_id)
      # find your user
    end

  end
end

To support custom Resource types, simply add a controller and provide the custom resource type via the resource_type method.