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
148 149 150 151 152 153 154 155 156 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 148 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
158 159 160 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 158 def (resource_owner) Doorkeeper.configuration..call(self, resource_owner) end |
#plaintext_secret ⇒ Object
140 141 142 143 144 145 146 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 140 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.
131 132 133 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 131 def redirect_uri=(uris) super(uris.is_a?(Array) ? uris.join("\n") : uris) end |
#renew_secret ⇒ Object
135 136 137 138 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 135 def renew_secret @raw_secret = Doorkeeper::OAuth::Helpers::UniqueToken.generate secret_strategy.store_secret(self, :secret, @raw_secret) end |
#secret_matches?(input) ⇒ Boolean
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 109 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 |