Module: DoorkeeperMongodb::Mixins::Mongoid::ApplicationMixin
- Extended by:
- ActiveSupport::Concern
- Includes:
- Doorkeeper::Models::Scopes, Doorkeeper::Models::SecretStorable, Doorkeeper::OAuth::Helpers, BaseMixin
- Included in:
- Doorkeeper::Application
- Defined in:
- lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #authorized_for_resource_owner?(resource_owner) ⇒ Boolean
- #plaintext_secret ⇒ Object
-
#redirect_uri=(uris) ⇒ String
Set an application’s valid redirect URIs.
- #renew_secret ⇒ Object
- #secret_matches?(input) ⇒ Boolean
Instance Method Details
#as_json(options = {}) ⇒ Object
224 225 226 227 228 229 230 231 232 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 224 def as_json( = {}) hash = super if hash.key?("_id") || ( && Array.wrap([:only]).include?(:id)) hash["id"] = id.to_s end hash["secret"] = plaintext_secret if hash.key?("secret") hash end |
#authorized_for_resource_owner?(resource_owner) ⇒ Boolean
234 235 236 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 234 def (resource_owner) Doorkeeper.configuration..call(self, resource_owner) end |
#plaintext_secret ⇒ Object
216 217 218 219 220 221 222 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 216 def plaintext_secret if secret_strategy.allows_restoring_secrets? secret_strategy.restore_secret(self, :secret) else @raw_secret end end |
#redirect_uri=(uris) ⇒ String
Set an application’s valid redirect URIs.
207 208 209 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 207 def redirect_uri=(uris) super(uris.is_a?(Array) ? uris.join("\n") : uris) end |
#renew_secret ⇒ Object
211 212 213 214 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 211 def renew_secret @raw_secret = Doorkeeper::OAuth::Helpers::UniqueToken.generate secret_strategy.store_secret(self, :secret, @raw_secret) end |
#secret_matches?(input) ⇒ Boolean
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 185 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 |