Skip to content

Commit

Permalink
add idp_host to trusted allowed_hostnames
Browse files Browse the repository at this point in the history
  • Loading branch information
stepchud committed Jan 16, 2025
1 parent b582a89 commit 178ce76
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/models/login_gov.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require 'uri'

# LoginGov manages authentication with the external login.gov service
Expand Down Expand Up @@ -105,11 +106,12 @@ def get_public_key(jwks_uri)
end

def validate_jwks_uri(uri)
allowed_hostnames = ["trusted-domain.com"]
idp_host = URI.parse(config[:idp_host]).host
allowed_hostnames = [idp_host]
uri_host = URI.parse(uri).host
unless allowed_hostnames.include?(uri_host)
raise LoginApiError.new("Invalid jwks_uri", code: 400, body: "The jwks_uri is not allowed.")
end
return if allowed_hostnames.include?(uri_host)

raise LoginApiError.new("Invalid jwks_uri", code: 400, body: "The jwks_uri is not allowed.")
end

def read_private_key
Expand Down

0 comments on commit 178ce76

Please sign in to comment.