0

Trying to follow the setup here to create a simple SAML application (full project I got here).

I went through and did the setup

bundle install
rails s

This went fine, but when I navigate to http://localhost:3000/ I get hit with

NoMethodError in SamlController#init
undefined method `+' for nil:NilClass
Extracted source (around line #9):
  def init
    request = OneLogin::RubySaml::Authrequest.new
    direct_to(request.create(saml_settings))
  end

  def consume

I added some logging to check nil status of request and saml_settings but that seems to return false for both of them

puts request.nil?
puts saml_settings.nil?

Error trace:

Processing by SamlController#init as HTML
false
false
Created AuthnRequest: <samlp:AuthnRequest AssertionConsumerServiceURL='http://localhost:3000/saml/consume' ID='_394fa0a0-f313-0135-85a4-6a0001e18280' IssueInstant='2018-02-13T17:42:45Z' Version='2.0' xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion' xmlns:samlp='urn:oasis:names:tc:SAML:2.0:protocol'><saml:Issuer>http://localhost:3000/saml/consume</saml:Issuer></samlp:AuthnRequest>
Completed 500 Internal Server Error in 15ms (ActiveRecord: 0.0ms)

NoMethodError (undefined method `+' for nil:NilClass):
  app/controllers/saml_controller.rb:9:in `init'

(Note: the error is line 5, it says line 9 for me because of debug logging I added) I'm not too sure what else it could be, not sure what method it can't find and what is nil?

I have never messed with ruby stuff, but from my initial looks I'm not sure where the nil is coming from, the logs show the request being created so not sure. Any help would be appreciated, thanks!

Maksim Kalmykov
  • 1,293
  • 3
  • 20
  • 26
Th3sandm4n
  • 809
  • 4
  • 13
  • 23

2 Answers2

0

Firstly I think you're using a pretty old ruby-saml gem version. That might be the problem.

I haven't tested your code, but it seems to me that you forgot to set idp_sso_target_url in your settings, and apparently that's the only place it can throw the exception you got. https://github.com/onelogin/ruby-saml/blob/v1.1.2/lib/onelogin/ruby-saml/authrequest.rb#L39

Paniko0
  • 528
  • 5
  • 11
  • I found the answer after digging around, the problem came from the saml_settings I think: settings = idp_metadata_parser.parse(ENV['OKTA_METADATA']) i had that as a remote URL, so I changed it to settings = idp_metadata_parser.parse_remote(ENV['OKTA_METADATA']) and that seemed to work! – Th3sandm4n Feb 13 '18 at 18:23
0

Posting the answer here, turns out that i was using a metadata url for the OKTA_METADATA environment variable.

Had to modify settings = idp_metadata_parser.parse(ENV['OKTA_METADATA']) to settings = idp_metadata_parser.parse_remote(ENV['OKTA_METADATA']) where OKTA_METADATA=http://blahblahblah.com/metadata

Th3sandm4n
  • 809
  • 4
  • 13
  • 23