Module: BetterAuth::Plugins::OIDCProvider

Defined in:
lib/better_auth/plugins/oidc_provider.rb

Constant Summary collapse

VALID_PROMPTS =
%w[none login consent create select_account].freeze

Class Method Summary collapse

Class Method Details

.normalize_issuer(value) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/better_auth/plugins/oidc_provider.rb', line 12

def normalize_issuer(value)
  uri = URI.parse(value.to_s)
  uri.query = nil
  uri.fragment = nil
  if uri.scheme == "http" && !["localhost", "127.0.0.1"].include?(uri.host)
    uri.scheme = "https"
  end
  uri.to_s.sub(%r{/+\z}, "")
rescue URI::InvalidURIError
  value.to_s.split(/[?#]/).first.sub(%r{/+\z}, "")
end

.parse_prompt(value) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/better_auth/plugins/oidc_provider.rb', line 24

def parse_prompt(value)
  prompts = value.to_s.split(/\s+/).select { |prompt| VALID_PROMPTS.include?(prompt) }
  if prompts.include?("none") && prompts.length > 1
    raise APIError.new("BAD_REQUEST", message: "invalid_request")
  end

  prompts.to_set
end