Skip to content

Commit

Permalink
[#33348323] update namespaces, classnames, and directory names to ref…
Browse files Browse the repository at this point in the history
…lect new strategy name
  • Loading branch information
joshskeen committed Jul 31, 2012
1 parent 4fa6e75 commit 62c916e
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 51 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
omniauth-saml (0.9.2)
omniauth-saml-rstr (0.1.0)
omniauth (~> 1.0)
uuid (~> 2.3)
xmlcanonicalizer (= 0.1.1)
Expand Down Expand Up @@ -59,7 +59,7 @@ DEPENDENCIES
guard (= 1.0.1)
guard-rspec (= 0.6.0)
nokogiri
omniauth-saml!
omniauth-saml-rstr!
pry
rack-test (= 0.6.1)
rspec (= 2.8)
Expand Down
5 changes: 5 additions & 0 deletions lib/omniauth-saml-rstr/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module OmniAuth
module SAML_RSTR
VERSION = "0.1.0"
end
end
2 changes: 1 addition & 1 deletion lib/omniauth-saml.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require 'omniauth/strategies/saml'
require 'omniauth/strategies/saml-rstr'
5 changes: 0 additions & 5 deletions lib/omniauth-saml/version.rb

This file was deleted.

Binary file added lib/omniauth/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

module OmniAuth
module Strategies
class SAML
class SAML_RSTR
include OmniAuth::Strategy

autoload :AuthRequest, 'omniauth/strategies/saml/auth_request'
autoload :AuthResponse, 'omniauth/strategies/saml/auth_response'
autoload :ValidationError, 'omniauth/strategies/saml/validation_error'
autoload :XMLSecurity, 'omniauth/strategies/saml/xml_security'
autoload :AuthRequest, 'omniauth/strategies/saml-rstr/auth_request'
autoload :AuthResponse, 'omniauth/strategies/saml-rstr/auth_response'
autoload :ValidationError, 'omniauth/strategies/saml-rstr/validation_error'
autoload :XMLSecurity, 'omniauth/strategies/saml-rstr/xml_security'

option :name_identifier_format, "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"

def request_phase
puts "request phase!!!!"
request = OmniAuth::Strategies::SAML::AuthRequest.new
redirect(request.create(options))
end
Expand All @@ -28,7 +27,7 @@ def callback_phase
return fail!(:invalid_ticket, 'Invalid SAML Ticket') if @name_id.nil? || @name_id.empty? || !response.valid?
super
rescue ArgumentError => e
fail!(:invalid_ticket, 'Invalid SAML Response')
fail!(:invalid_ticket, 'Invalid SAML-RSTR Response')
end
end

Expand All @@ -46,4 +45,4 @@ def callback_phase
end
end

OmniAuth.config.add_camelization 'saml', 'SAML'
OmniAuth.config.add_camelization 'saml', 'SAML'
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

module OmniAuth
module Strategies
class SAML
class SAML_RSTR
class AuthRequest

def create(settings, params = {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module OmniAuth
module Strategies
class SAML
class SAML_RSTR
class AuthResponse

ASSERTION = "urn:oasis:names:tc:SAML:2.0:assertion"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module OmniAuth
module Strategies
class SAML
class SAML_RSTR
class ValidationError < Exception
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,21 @@

module OmniAuth
module Strategies
class SAML
class SAML_RSTR

module XMLSecurity

class SecurityTokenResponseContent


#plugging these namespaces in was required in order to get nokogiri to use them. eg @xml.at_xpath("//ds:SignatureValue", {"ds" => DSIG}).text. Any way to avoid this?
DSIG = "http://www.w3.org/2000/09/xmldsig#"
SAML = "urn:oasis:names:tc:SAML:1.0:assertion"
WSP = "http://schemas.xmlsoap.org/ws/2004/09/policy"
WSA = "http://www.w3.org/2005/08/addressing"
WSU = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
TRUST = "http://schemas.xmlsoap.org/ws/2005/02/trust"

# {"xmlns:wsu"=>
# "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd",
# "xmlns:t"=>"http://schemas.xmlsoap.org/ws/2005/02/trust",
# "xmlns:wsa"=>"http://www.w3.org/2005/08/addressing",
# "xmlns:wsp"=>"http://schemas.xmlsoap.org/ws/2004/09/policy",
# "xmlns:saml"=>"urn:oasis:names:tc:SAML:1.0:assertion",
# "xmlns:ds"=>"http://www.w3.org/2000/09/xmldsig#",
# "xmlns"=>"http://www.w3.org/2000/09/xmldsig#"}

attr_accessor :name_identifier, :xml, :xml_unnamespaced, :name_identifier_test, :x509_cert, :conditions_not_on_or_after, :conditions_before, :info_element

def initialize(response)
Expand Down Expand Up @@ -92,7 +85,6 @@ def x509_cert
#validate the response fingerprint matches the plugin fingerprint
#validate the certificate signature matches the signature generated from signing the certificate's SignedInfo node
def validate(idp_cert_fingerprint, idp_cert=null, soft=true )
puts ">>>>"
if idp_cert
decoded_cert_text = Base64.decode64(idp_cert)
else
Expand All @@ -105,8 +97,6 @@ def validate(idp_cert_fingerprint, idp_cert=null, soft=true )
end
canon_string = info_element.canonicalize(Nokogiri::XML::XML_C14N_EXCLUSIVE_1_0)
sig = Base64.decode64(signature)

puts "certificate validation??? " + certificate.public_key.verify(OpenSSL::Digest::SHA256.new, sig, canon_string)
if !certificate.public_key.verify(OpenSSL::Digest::SHA256.new, sig, canon_string)
raise OmniAuth::Strategies::SAML::ValidationError.new("Signature validation error")
end
Expand Down
4 changes: 2 additions & 2 deletions omniauth-saml.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ require File.expand_path('../lib/omniauth-saml-rstr/version', __FILE__)

Gem::Specification.new do |gem|
gem.name = "omniauth-saml-rstr"
gem.version = OmniAuth::SAML::VERSION
gem.version = OmniAuth::SAML_RSTR::VERSION
gem.summary = %q{A generic SAML strategy for OmniAuth.}
gem.description = %q{A generic SAML strategy for OmniAuth.}

gem.authors = ["Raecoo Cao", "Ryan Wilcox", "Rajiv Aaron Manglani", "Steven Anderson"]
gem.email = "rajiv@alum.mit.edu"
gem.homepage = "https://github.com/PracticallyGreen/omniauth-saml"
gem.homepage = "https://github.com/mutexkid/omniauth-saml-rstr"

gem.add_runtime_dependency 'omniauth', '~> 1.0'
gem.add_runtime_dependency 'xmlcanonicalizer', '0.1.1'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require 'spec_helper'

describe OmniAuth::Strategies::SAML::AuthRequest do
describe OmniAuth::Strategies::SAML_RSTR::AuthRequest do
describe :create do
let(:url) do
described_class.new.create(
{
:idp_sso_target_url => 'example.com',
:assertion_consumer_service_url => 'http://example.com/auth/saml/callback',
:assertion_consumer_service_url => 'http://example.com/auth/saml-rstr/callback',
:issuer => 'This is an issuer',
:name_identifier_format => 'Some Policy'
},
Expand Down Expand Up @@ -60,7 +60,7 @@
end

it "should contain the callback url in the settings" do
root_element.attributes['AssertionConsumerServiceURL'].should == 'http://example.com/auth/saml/callback'
root_element.attributes['AssertionConsumerServiceURL'].should == 'http://example.com/auth/saml-rstr/callback'
end

it "should contain the issuer" do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe OmniAuth::Strategies::SAML::AuthResponse do
describe OmniAuth::Strategies::SAML_RSTR::AuthResponse do
let(:xml) { :rstr_response }
subject { described_class.new(load_xml(xml)) }

Expand Down
5 changes: 5 additions & 0 deletions spec/omniauth/strategies/saml-rstr/validation_error_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'spec_helper'

describe OmniAuth::Strategies::SAML_RSTR::ValidationError do
it { should be_a Exception }
end
5 changes: 0 additions & 5 deletions spec/omniauth/strategies/saml/validation_error_spec.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
end

def post_xml(xml=:rstr_response)
post "/auth/saml/callback", {'wresult' => load_xml(xml)}
post "/auth/saml-rstr/callback", {'wresult' => load_xml(xml)}
end

describe OmniAuth::Strategies::SAML, :type => :strategy do
describe OmniAuth::Strategies::SAML_RSTR, :type => :strategy do
include OmniAuth::Test::StrategyTestCase

let(:auth_hash){ last_request.env['omniauth.auth'] }
let(:saml_options) do
{
:assertion_consumer_service_url => "http://localhost:3000/auth/saml/callback",
:assertion_consumer_service_url => "http://localhost:3000/auth/saml-rstr/callback",
:issuer => "https://saml.issuer.url/issuers/29490",
:idp_sso_target_url => "https://idp.sso.target_url/signon/29490",
:idp_cert_fingerprint => "E6:87:89:FB:F2:5F:CD:B0:31:32:7E:05:44:84:53:B1:EC:4E:3F:FA",
Expand All @@ -25,17 +25,17 @@ def post_xml(xml=:rstr_response)
end
let(:strategy) { [OmniAuth::Strategies::SAML, saml_options] }

describe 'GET /auth/saml' do
describe 'GET /auth/saml-rstr' do
before do
get '/auth/saml'
get '/auth/saml-rstr'
end

it 'should get authentication page' do
last_response.should be_redirect
end
end

describe 'POST /auth/saml/callback' do
describe 'POST /auth/saml-rstr/callback' do
subject { last_response }

let(:xml) { :rstr_response }
Expand All @@ -62,7 +62,7 @@ def post_xml(xml=:rstr_response)

context "when there is no wresult parameter" do
before :each do
post '/auth/saml/callback'
post '/auth/saml-rstr/callback'
end

it { should fail_with(:invalid_ticket) }
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'simplecov'
SimpleCov.start

require 'omniauth-saml'
require 'omniauth-saml-rstr'
require 'rack/test'
require 'rexml/document'
require 'rexml/xpath'
Expand Down

0 comments on commit 62c916e

Please sign in to comment.