Skip to content

Add support for the wfresh option #29

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

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ posted. Defaults to the OmniAuth callback URL. **Optional**

* `:saml_version` - The version of SAML tokens. **Defaults to 2**.

* `:wfresh` - Indicates the freshness requirements (the maximum authentication age in minutes). **Optional**.

## Authors and Credits ##

Expand Down
7 changes: 6 additions & 1 deletion lib/omniauth/strategies/wsfed/auth_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,23 @@ def wsfed_signin_request
wreply = url_encode(strategy_settings[:reply])
wct = url_encode(Time.now.utc)
whr = url_encode(args[:whr])
wfresh = url_encode(strategy_settings[:wfresh])

query_string = "?wa=#{wa}&wtrealm=#{wtrealm}&wreply=#{wreply}&wctx=#{}&wct=#{wct}"

unless whr.nil? or whr.empty?
query_string = "#{query_string}&whr=#{whr}"
end

unless wfresh.nil? or wfresh.empty?
query_string = "#{query_string}&wfresh=#{wfresh}"
end

strategy_settings[:issuer] + query_string
end

end

end
end
end
end
9 changes: 7 additions & 2 deletions spec/omniauth/strategies/wsfed/auth_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
:issuer => 'https://c4sc.accesscontrol.windows.net.com/v2/wsfederation',
:realm => 'http://c4sc.com/security_realm',
:reply => 'http://rp.c4sc.com/auth/wsfed',
:home_realm_discovery_path => 'auth/home_realm_discovery'
:home_realm_discovery_path => 'auth/home_realm_discovery',
:wfresh => 0
}
end

Expand Down Expand Up @@ -85,6 +86,10 @@
request.wsfed_signin_request.should include "wct=#{ERB::Util.url_encode(time)}"
end

it 'should include the freshness param [wfresh]' do
request.wsfed_signin_request.should include "wfresh=0"
end

describe 'Url-Encoded Home Realm Parameter [whr]' do

let(:home_realm) { 'http://identity.c4sc.com/trust' }
Expand All @@ -104,4 +109,4 @@

end

end
end