Class: Marty::ApiAuth
- Inherits:
-
Base
- Object
- ActiveRecord::Base
- Base
- Marty::ApiAuth
- Defined in:
- app/models/marty/api_auth.rb
Defined Under Namespace
Classes: ApiAuthValidator
Constant Summary collapse
- KEY_SIZE =
19
Constants inherited from Base
Base::COUNT_SIG, Base::DISTINCT_SIG, Base::FIRST_SIG, Base::GROUP_SIG, Base::JOINS_SIG, Base::LAST_SIG, Base::LIMIT_SIG, Base::MCFLY_PT_SIG, Base::NOT_SIG, Base::ORDER_SIG, Base::PLUCK_SIG, Base::SELECT_SIG, Base::WHERE_SIG
Class Method Summary collapse
Methods inherited from Base
Methods inherited from ActiveRecord::Base
Class Method Details
.authorized?(script_name, api_key) ⇒ Boolean
37 38 39 40 41 42 43 |
# File 'app/models/marty/api_auth.rb', line 37 def self.(script_name, api_key) is_secured = where(script_name: script_name, obsoleted_dt: 'infinity').exists? !is_secured || where(api_key: api_key, script_name: script_name, obsoleted_dt: 'infinity').pluck(:app_name).first end |
.generate_key ⇒ Object
6 7 8 |
# File 'app/models/marty/api_auth.rb', line 6 def self.generate_key SecureRandom.hex(KEY_SIZE) end |