Module: SMARTAppLaunch::RegistrationVerification

Instance Method Summary collapse

Instance Method Details

#normalize_urls(url_list, type_for_error) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/smart_app_launch/client_suite/registration_verification.rb', line 34

def normalize_urls(url_list, type_for_error)
  url_list.split(',').map(&:strip).each_with_object([]) do |url, normalized_urls|
    next if url.blank?

    parsed_uri =
      begin
        URI.parse(url)
      rescue URI::InvalidURIError
        add_message('error', "Registered #{type_for_error} '#{url}' is not a valid URI.")
        nil
      end
    next unless parsed_uri.present?
    unless parsed_uri.scheme == 'https' || parsed_uri.scheme == 'http'
      add_message('error', "Registered #{type_for_error} '#{url}' is not a valid http address.")
      next
    end

    normalized_urls << url
    unless parsed_uri.scheme == 'https'
      add_message('error', "Registered #{type_for_error} '#{url}' is not a valid https URI.")
    end
  end
end

#verify_registered_jwks(jwks_input) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/smart_app_launch/client_suite/registration_verification.rb', line 3

def verify_registered_jwks(jwks_input)

  jwks_warnings = []
  parsed_smart_jwk_set = MockSMARTServer.jwk_set(smart_jwk_set, jwks_warnings)
  jwks_warnings.each { |warning| add_message('warning', warning) }

  # TODO: add key-specific verification per end of https://build.fhir.org/ig/HL7/smart-app-launch/client-confidential-asymmetric.html#registering-a-client-communicating-public-keys

  unless parsed_smart_jwk_set.length.positive?
    add_message(
      'error',
      'JWKS content for Confidential Asymmetric authentication does not include any valid keys.'
    )
  end
end

#verify_registered_launch_urls(launch_urls) ⇒ Object



19
20
21
22
23
24
# File 'lib/smart_app_launch/client_suite/registration_verification.rb', line 19

def verify_registered_launch_urls(launch_urls)
  return unless launch_urls.present?

  normalized_launch_urls = normalize_urls(launch_urls, 'launch URL')
  output smart_launch_urls: normalized_launch_urls.join(',').strip
end

#verify_registered_redirect_uris(redirect_uris) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/smart_app_launch/client_suite/registration_verification.rb', line 26

def verify_registered_redirect_uris(redirect_uris)
  return unless redirect_uris.present?

  normalized_redirect_uris = normalize_urls(redirect_uris, 'redirect URI')

  output smart_redirect_uris: normalized_redirect_uris.join(',').strip
end