Sha256: 69f148b172360d99f83d96517095aad0d9b375601b72737df8d99a8ed34b416f
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
module ScimRails class ApplicationController < ActionController::API include ActionController::HttpAuthentication::Basic::ControllerMethods include ExceptionHandler include Response before_action :authorize_request private def authorize_request send(authentication_strategy) do |searchable_attribute, authentication_attribute| authorization = AuthorizeApiRequest.new( searchable_attribute: searchable_attribute, authentication_attribute: authentication_attribute ) @company = authorization.company end raise ScimRails::ExceptionHandler::InvalidCredentials if @company.blank? end def authentication_strategy if request.headers["Authorization"]&.include?("Bearer") :authenticate_with_oauth_bearer else :authenticate_with_http_basic end end def authenticate_with_oauth_bearer authentication_attribute = request.headers["Authorization"].split(" ").last payload = ScimRails::Encoder.decode(authentication_attribute).with_indifferent_access searchable_attribute = payload[ScimRails.config.basic_auth_model_searchable_attribute] yield searchable_attribute, authentication_attribute end end end
Version data entries
3 entries across 3 versions & 1 rubygems