Commit f168f65
Changed files (3)
lib
scim
spec
scim
lib/scim/shady/builders/service_provider_configuration.rb
@@ -5,6 +5,12 @@ module Scim
attr_accessor :documentation_uri
attr_accessor :patch
attr_accessor :change_password_supported
+ attr_accessor :sort_supported
+ attr_accessor :etag_supported
+
+ def initialize
+ @authentication_schemes = []
+ end
def bulk
@bulk = Bulk.new
@@ -16,6 +22,26 @@ module Scim
yield @filter
end
+ def add_authentication_scheme(type)
+ if :oauth_bearer_token == type
+ @authentication_schemes.push({
+ "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",
+ })
+ elsif :http_basic == type
+ @authentication_schemes.push({
+ "name" => "HTTP Basic",
+ "description" => "Authentication scheme using the HTTP Basic Standard",
+ "specUri" => "http://www.rfc-editor.org/info/rfc2617",
+ "documentationUri" => "http://example.com/help/httpBasic.html",
+ "type" => "httpbasic",
+ })
+ end
+ end
+
def build
Scim::Shady::ServiceProviderConfiguration.new(to_json)
end
@@ -33,7 +59,17 @@ module Scim
'filter' => @filter.to_h,
'changePassword' => {
'supported' => change_password_supported,
- }
+ },
+ 'sort' => {
+ 'supported' => sort_supported,
+ },
+ 'etag' => {
+ 'supported' => etag_supported,
+ },
+ 'authenticationSchemes' => @authentication_schemes.each_with_index.map do |scheme, index|
+ scheme['primary'] = true if index.zero?
+ scheme
+ end
}
end
lib/scim/shady/service_provider_configuration.rb
@@ -37,6 +37,18 @@ module Scim
to_h['changePassword']['supported']
end
+ def sort_supported
+ to_h['sort']['supported']
+ end
+
+ def etag_supported
+ to_h['etag']['supported']
+ end
+
+ def authentication_schemes
+ to_h['authenticationSchemes']
+ end
+
def to_h
@hash ||= JSON.parse(to_json)
end
spec/scim/builders/service_provider_configuration_spec.rb
@@ -45,5 +45,39 @@ RSpec.describe Scim::Shady::Builders::ServiceProviderConfiguration do
result = subject.build
expect(result.change_password_supported).to be(true)
end
+
+ it 'can configure sort support' do
+ subject.sort_supported = true
+ expect(subject.build.sort_supported).to be(true)
+ end
+
+ it 'can configure etag support' do
+ subject.etag_supported = true
+ expect(subject.build.etag_supported).to be(true)
+ end
+
+ it 'can add authentication schemes' do
+ subject.add_authentication_scheme(:oauth_bearer_token)
+ subject.add_authentication_scheme(:http_basic)
+
+ result = subject.build
+ expect(result.authentication_schemes).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,
+ },
+ {
+ "name" => "HTTP Basic",
+ "description" => "Authentication scheme using the HTTP Basic Standard",
+ "specUri" => "http://www.rfc-editor.org/info/rfc2617",
+ "documentationUri" => "http://example.com/help/httpBasic.html",
+ "type" => "httpbasic",
+ }
+ ])
+ end
end
end