main
1# frozen_string_literal: true
2
3class Idp
4 class << self
5 def default(request)
6 @default ||=
7 begin
8 host = "#{request.protocol}#{request.host}:#{request.port}"
9 url_helpers = Rails.application.routes.url_helpers
10 Saml::Kit::Metadata.build do |builder|
11 builder.embed_signature = false
12 builder.contact_email = 'hi@example.com'
13 builder.organization_name = "Acme, Inc"
14 builder.organization_url = url_helpers.root_url(host: host)
15 builder.build_identity_provider do |x|
16 x.add_single_sign_on_service(
17 url_helpers.new_session_url(host: host), binding: :http_post
18 )
19 x.add_single_sign_on_service(
20 url_helpers.new_session_url(host: host), binding: :http_redirect
21 )
22 x.add_single_logout_service(
23 url_helpers.logout_url(host: host), binding: :http_post
24 )
25 x.name_id_formats = [
26 Saml::Kit::Namespaces::EMAIL_ADDRESS,
27 Saml::Kit::Namespaces::PERSISTENT,
28 Saml::Kit::Namespaces::TRANSIENT,
29 ]
30 x.attributes << :id
31 x.attributes << :email
32 x.attributes << :created_at
33 end
34 end
35 end
36 end
37 end
38end