Module: Doorkeeper::ApplicationMixin

Extended by:
ActiveSupport::Concern
Includes:
Models::Orderable, Models::Scopes, Models::SecretStorable, OAuth::Helpers
Defined in:
lib/doorkeeper/models/application_mixin.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from Models::Scopes

#includes_scope?, #scopes, #scopes=, #scopes_string

Instance Method Details

#redirect_uri=(uris) ⇒ String

Set an application’s valid redirect URIs.

Parameters:

  • uris (String, Array<String>)

    Newline-separated string or array the URI(s)

Returns:

  • (String)

    The redirect URI(s) separated by newlines.



67
68
69
# File 'lib/doorkeeper/models/application_mixin.rb', line 67

def redirect_uri=(uris)
  super(uris.is_a?(Array) ? uris.join("\n") : uris)
end

#secret_matches?(input) ⇒ Boolean

Check whether the given plain text secret matches our stored secret

Parameters:

  • input (#to_s)

    Plain secret provided by user (any object that responds to ‘#to_s`)

Returns:

  • (Boolean)

    Whether the given secret matches the stored secret of this application.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/doorkeeper/models/application_mixin.rb', line 79

def secret_matches?(input)
  # return false if either is nil, since secure_compare depends on strings
  # but Application secrets MAY be nil depending on confidentiality.
  return false if input.nil? || secret.nil?

  # When matching the secret by comparer function, all is well.
  return true if secret_strategy.secret_matches?(input, secret)

  # When fallback lookup is enabled, ensure applications
  # with plain secrets can still be found
  if fallback_secret_strategy
    fallback_secret_strategy.secret_matches?(input, secret)
  else
    false
  end
end