Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OmniAuth::Strategies::WSFed::AuthRequest#wsfed_signin_request URL build fixed. #28

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions lib/omniauth/strategies/wsfed/auth_request.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
require 'erb'

module OmniAuth
module Strategies
class WSFed

class AuthRequest
include ERB::Util

SIGNIN_PARAM = 'wsignin1.0'

attr_reader :strategy_settings, :args
Expand All @@ -27,23 +22,23 @@ def redirect_url
end

def wsfed_signin_request
wa = SIGNIN_PARAM
wtrealm = url_encode(strategy_settings[:realm])
wreply = url_encode(strategy_settings[:reply])
wct = url_encode(Time.now.utc)
whr = url_encode(args[:whr])
issuer_url_new_params = {
wa: SIGNIN_PARAM,
wtrealm: strategy_settings[:realm],
wreply: strategy_settings[:reply],
wct: Time.now.utc,
wctx: nil,
}

query_string = "?wa=#{wa}&wtrealm=#{wtrealm}&wreply=#{wreply}&wctx=#{}&wct=#{wct}"
new_issuer_params[:whr] = args[:whr] if args[:whr].present?

unless whr.nil? or whr.empty?
query_string = "#{query_string}&whr=#{whr}"
end
issuer_url = URI.parse(strategy_settings[:issuer])
issuer_url_params = issuer_url.query.present? ? Hash[CGI.parse(issuer_url.query).map{ |key,values| [ key.to_sym, values[0] || true ] } ] : {}
issuer_url.query = URI.encode_www_form(issuer_url_params.merge(issuer_url_new_params))

strategy_settings[:issuer] + query_string
issuer_url.to_s
end

end

end
end
end
end