Giter Site home page Giter Site logo

Comments (2)

sheffy-kalra avatar sheffy-kalra commented on August 22, 2024

Hi Vikas,

Loo into below URL. This may helps you to generate, calculate Digest value and Signature Value.
https://stackoverflow.com/questions/23394654/signing-a-xml-document-with-x509-certificate

from libsaml.

benoist avatar benoist commented on August 22, 2024

This library was first created to work with DigiD so it's relatively easy to make it happen. You just need to know what to configure :)

In order to connect to DigiD, you have to deliver the SAML metadata which contains the entity id and the signing and encryption certificates.
The signature value and digest value will be automatically filled in if you sign the Metadata object with your private key.

First make sure you configure your Saml store where the metadata from DigiD is located and your private key is configured

Saml.setup do |config|
  config.register_store :file, Saml::ProviderStores::File.new("config/metadata", "config/ssl/key.pem"), default: true
end

SAML metadata or entity descriptors can be made like this:

  def entity_descriptor
    signing_key_descriptor    = Saml::Elements::KeyDescriptor.new(certificate: "<PEM>", use: 'signing')
    encryption_key_descriptor = Saml::Elements::KeyDescriptor.new(certificate: "<PEM>", use: 'encryption')

    assertion_consumer_service = Saml::Elements::SPSSODescriptor::AssertionConsumerService.new(
        binding:  Saml::ProtocolBinding::HTTP_ARTIFACT,
        index:    0,
        location: "<receive artifact url>"
    )

    single_logout_service = Saml::Elements::SPSSODescriptor::SingleLogoutService.new(
      location: "<receive logout url>",
      binding: Saml::ProtocolBinding::HTTP_REDIRECT
    )

    sp_sso_descriptor = Saml::Elements::SPSSODescriptor.new(
        assertion_consumer_services: [assertion_consumer_service],
        single_logout_services:      [single_logout_service],
        key_descriptors:             [signing_key_descriptor, encryption_key_descriptor]
    )

    entity_descriptor                   = Saml::Elements::EntityDescriptor.new(entity_id: "<entity_id>")
    entity_descriptor.sp_sso_descriptor = sp_sso_descriptor

    entity_descriptor
  end

Make sure you change values to your specific case.

You can sign any message with the util function

Saml::Util.sign_xml(entity_descriptor)

For the implementation of the Service Provider, you can follow the example in the readme.

from libsaml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.