How to generate and share SP SAML 2.0 metadata in rails

戏子无情 提交于 2019-12-08 10:30:28

问题


I have this one which is I guess is following SAML 1.1, I wanted to know how can I generate a new SP metadata using SAML 2.0 in Rails and share with other users, which will help other team in configuring SAML at IDp(Identity Provider end)?

require 'onelogin/saml'
class Account < ActiveRecord::Base
    def get_settings
        settings = Onelogin::Saml::Settings.new    
        settings.issuer                          = "https://example.com/test"    
        settings.idp_sso_target_url                ="https://testexample.com"  
        settings.idp_cert_fingerprint             ="########"
        settings.relying_party_identifier         = "knsdfnsdf"    
        settings.assertion_consumer_service_url   = "https://www.example.com/consume?http_referer=https://testexample.com"
        settings.idp_confirmation_method          = "urn:oasis:names:tc:SAML:1.0:cm:bearer"
        settings.asserting_party_id               = "23424dfsdf"            
        settings.referer_url = "https://textexample.com" 
        settings.groups                           = ["USER"]
        return settings, Onelogin::Saml::Metadata.new
      end
   end
     def saml_metadata
         settings, meta = Account.get_settings
         render :xml => meta.generate(settings)
      end

Is there any way by which I can generate it and share it with the IDp to configure SAML process.

Update:

I am able to get the metadata using the above code now. I just want to be sure that it is SAML 2.0. How can I tell that?

The xml that I get from the above code:

  <md:EntityDescriptor entityID="https://example.com/test">
    <md:SPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol" AuthnRequestsSigned="false" WantAssertionsSigned="true">
     <md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://www.example.com/consume?http_referer=https://testexample.com" isDefault="true" index="0"/>
    </md:SPSSODescriptor>
   </md:EntityDescriptor>

Plese note: the above code will only work if you are using ruby-saml version 0.7.x, as there is a syntax change from 0.8.x onwards.

来源:https://stackoverflow.com/questions/38204139/how-to-generate-and-share-sp-saml-2-0-metadata-in-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!