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
DEPRECATION_MESSAGE =
'The "oidc-provider" plugin is deprecated and will be removed in the next major version. Migrate to better_auth-oauth-provider. See: https://www.better-auth.com/docs/plugins/oauth-provider'

Class Method Summary collapse

Class Method Details

.normalize_issuer(value) ⇒ Object



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

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



36
37
38
39
40
41
42
43
# File 'lib/better_auth/plugins/oidc_provider.rb', line 36

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

.reset_deprecation_warning!Object



20
21
22
# File 'lib/better_auth/plugins/oidc_provider.rb', line 20

def reset_deprecation_warning!
  @deprecation_warned = false
end

.warn_deprecation!(logger = nil) ⇒ Object



13
14
15
16
17
18
# File 'lib/better_auth/plugins/oidc_provider.rb', line 13

def warn_deprecation!(logger = nil)
  return if @deprecation_warned

  Deprecate.warn_once("[Deprecation] #{DEPRECATION_MESSAGE}", logger)
  @deprecation_warned = true
end