Commit 6e6b2dc

mo <mo.khan@gmail.com>
2019-01-05 19:41:20
use scim-kit to generate sp config
1 parent aa55333
Changed files (5)
app/controllers/scim/v2/service_providers_controller.rb
@@ -12,25 +12,13 @@ module Scim
       private
 
       def configuration
-        Scim::Shady::ServiceProviderConfig.build do |x|
-          x.documentation_uri = root_url + "doc"
-          x.patch = false
-          x.bulk do |y|
-            y.supported = false
-          end
-          x.filter do |y|
-            y.supported = false
-          end
-          x.change_password_supported = false
-          x.sort_supported = false
-          x.etag_supported = false
-          x.add_authentication_scheme(:oauth_bearer_token)
-          x.meta do |y|
-            y.location = scim_v2_ServiceProviderConfig_url
-            y.created_at = y.updated_at = Time.now
-            y.version = 1
-          end
-        end
+        x = Scim::Kit::V2::ServiceProviderConfiguration.new(
+          location: scim_v2_ServiceProviderConfig_url
+        )
+        x.documentation_uri = documentation_url
+        x.add_authentication(:oauthbearertoken, primary: true)
+        x.meta.version = 1
+        x
       end
     end
   end
config/routes.rb
@@ -57,5 +57,8 @@ Rails.application.routes.draw do
     end
   end
   get "/.well-known/oauth-authorization-server", to: "oauth/metadata#show"
+  direct :documentation do
+    root_url + 'doc'
+  end
   root to: "sessions#new"
 end
spec/requests/scim/v2/service_provider_config_spec.rb
@@ -28,7 +28,12 @@ describe "/ServiceProviderConfig" do
     specify { expect(json[:changePassword][:supported]).to be(false) }
     specify { expect(json[:sort][:supported]).to be(false) }
     specify { expect(json[:etag][:supported]).to be(false) }
-    specify { expect(json[:authenticationSchemes]).to match_array([name: 'OAuth Bearer Token', description: 'Authentication scheme using the OAuth Bearer Token Standard', specUri: 'http://www.rfc-editor.org/info/rfc6750', documentationUri: 'http://example.com/help/oauth.html', type: 'oauthbearertoken', primary: true]) }
+    specify { expect(json[:authenticationSchemes][0][:name]).to eql('OAuth Bearer Token') }
+    specify { expect(json[:authenticationSchemes][0][:description]).to eql('Authentication scheme using the OAuth Bearer Token Standard') }
+    specify { expect(json[:authenticationSchemes][0][:specUri]).to eql('http://www.rfc-editor.org/info/rfc6750') }
+    specify { expect(json[:authenticationSchemes][0][:documentationUri]).to eql('http://example.com/help/oauth.html') }
+    specify { expect(json[:authenticationSchemes][0][:type]).to eql('oauthbearertoken') }
+    specify { expect(json[:authenticationSchemes][0][:primary]).to be(true) }
     specify { expect(json[:meta][:location]).to eql(scim_v2_ServiceProviderConfig_url) }
     specify { expect(json[:meta][:resourceType]).to eql('ServiceProviderConfig') }
     specify { expect(json[:meta][:created]).to be_present }
Gemfile
@@ -22,7 +22,7 @@ gem 'puma', '~> 3.11'
 gem 'rails', '~> 5.2.0'
 gem 'rotp', '~> 3.3'
 gem 'saml-kit', '~> 1.0'
-gem 'scim-kit'
+gem 'scim-kit', '~> 0.2'
 gem 'scim-shady', '~> 0.2'
 gem 'spank', '~> 1.0'
 gem 'turbolinks', '~> 5'
Gemfile.lock
@@ -290,7 +290,7 @@ GEM
     sass-listen (4.0.0)
       rb-fsevent (~> 0.9, >= 0.9.4)
       rb-inotify (~> 0.9, >= 0.9.7)
-    scim-kit (0.1.0)
+    scim-kit (0.2.0)
       tilt (~> 2.0)
       tilt-jbuilder (~> 0.7)
     scim-shady (0.2.1)
@@ -387,7 +387,7 @@ DEPENDENCIES
   rubocop (~> 0.59)
   rubocop-rspec (~> 1.30)
   saml-kit (~> 1.0)
-  scim-kit
+  scim-kit (~> 0.2)
   scim-shady (~> 0.2)
   selenium-webdriver (~> 3.14)
   spank (~> 1.0)