class OmniAuth::Strategies::Crowd::Configuration
Constants
- DEFAULT_AUTHENTICATION_URL
- DEFAULT_CONTENT_TYPE
- DEFAULT_SESSION_URL
- DEFAULT_USER_GROUP_URL
- IS_NOT_URL_ERROR_MESSAGE
Attributes
Public Class Methods
@param [Hash] params configuration options @option params [String, nil] :crowd_server_url the Crowd server root URL; probably something like
`https://crowd.mycompany.com` or `https://crowd.mycompany.com/crowd`; optional.
@option params [String, nil] :crowd_authentication_url (:crowd_server_url + '/rest/usermanagement/latest/authentication') the URL to which to
use for authenication; optional if `:crowd_server_url` is specified, required otherwise.
@option params [String, nil] :application_name the application name specified in Crowd for this application, required. @option params [String, nil] :application_password the application password specified in Crowd for this application, required. @option params [Boolean, nil] :disable_ssl_verification disable verification for SSL cert,
helpful when you developing with a fake cert.
@option params [Boolean, true] : include a list of user groups when getting information ont he user @option params [String, nil] :crowd_user_group_url (:crowd_server_url + '/rest/usermanagement/latest/user/group/direct') the URL to which to
use for retrieving users groups optional if `:crowd_server_url` is specified, or if `:include_user_groups` is false required otherwise.
# File lib/omniauth/strategies/crowd/configuration.rb, line 32 def initialize(params) parse_params params end
Public Instance Methods
Build a Crowd authentication URL from
username
.
@param [String] username the username to validate
@return [String] a URL like `crowd.myhost.com/crowd/rest/usermanagement/latest/authentication?username=USERNAME`
# File lib/omniauth/strategies/crowd/configuration.rb, line 41 def authentication_url(username) append_username @authentication_url, username end
# File lib/omniauth/strategies/crowd/configuration.rb, line 45 def user_group_url(username) @user_group_url.nil? ? nil : append_username( @user_group_url, username) end
Private Instance Methods
Adds service
as an URL-escaped parameter to base
.
@param [String] base the base URL @param [String] service the service (a.k.a. return-to) URL.
@return [String] the new joined URL.
# File lib/omniauth/strategies/crowd/configuration.rb, line 92 def append_username(base, username) result = base.dup result << (result.include?('?') ? '&' : '?') result << 'username=' result << Rack::Utils.escape(username) end
# File lib/omniauth/strategies/crowd/configuration.rb, line 50 def parse_params(options) options= {:include_user_groups => true}.merge(options || {}) %w(application_name application_password).each do |opt| raise ArgumentError.new(":#{opt} MUST be provided") if options[opt.to_sym] == "" end @crowd_application_name = options[:application_name] @crowd_password = options[:application_password] @use_sessions = options[:use_sessions] @content_type = options[:content_type] || DEFAULT_CONTENT_TYPE unless options.include?(:crowd_server_url) || options.include?(:crowd_authentication_url) raise ArgumentError.new("Either :crowd_server_url or :crowd_authentication_url MUST be provided") end if @use_sessions @session_url = options[:crowd_session_url] || DEFAULT_SESSION_URL % options[:crowd_server_url] validate_is_url 'session URL', @session_url end @authentication_url = options[:crowd_authentication_url] || DEFAULT_AUTHENTICATION_URL % options[:crowd_server_url] validate_is_url 'authentication URL', @authentication_url @disable_ssl_verification = options[:disable_ssl_verification] @include_users_groups = options[:include_user_groups] if @include_users_groups @user_group_url = options[:crowd_user_group_url] || DEFAULT_USER_GROUP_URL % options[:crowd_server_url] validate_is_url 'user group URL', @user_group_url end end
# File lib/omniauth/strategies/crowd/configuration.rb, line 81 def validate_is_url(name, possibly_a_url) url = URI.parse(possibly_a_url) rescue nil raise ArgumentError.new(IS_NOT_URL_ERROR_MESSAGE % name) unless url.kind_of?(URI::HTTP) end