Class: Core::Models::OAuth::Application
- Inherits:
-
Object
- Object
- Core::Models::OAuth::Application
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/core/models/oauth/application.rb
Overview
An application is what is referred to in the OAuth2.0 RFC as a client, wanting to access private informations about the user.
Instance Attribute Summary collapse
-
#authorizations ⇒ Array<Core::Models::OAuth::Authorization>
The authorizations linked to the accounts this application can get the data from.
-
#client_id ⇒ String
The unique key for the application, identifying it when requesting a token for the API.
-
#client_secret ⇒ String
The “password” of the application, used to identify it when requesting tokens.
-
#creator ⇒ Core::Models::Account
The account that has created this application, considered its owner.
-
#name ⇒ String
The unique name of the application, mainly used to identify and display it.
-
#premium ⇒ Boolean
A value indicating whether the application should automatically receive a token when an account is created, or not.
Instance Method Summary collapse
-
#redirect_uris_values ⇒ Object
Checks the URIs to get sure they are correct, a URI is correct if : - it is a string - it has a correct URL format.
Instance Attribute Details
#authorizations ⇒ Array<Core::Models::OAuth::Authorization>
Returns the authorizations linked to the accounts this application can get the data from.
33 |
# File 'lib/core/models/oauth/application.rb', line 33 has_many :authorizations, class_name: 'Core::Models::OAuth::Authorization', inverse_of: :application |
#client_id ⇒ String
Returns the unique key for the application, identifying it when requesting a token for the API.
17 |
# File 'lib/core/models/oauth/application.rb', line 17 field :client_id, type: String, default: ->{ SecureRandom.hex } |
#client_secret ⇒ String
Returns the “password” of the application, used to identify it when requesting tokens.
20 |
# File 'lib/core/models/oauth/application.rb', line 20 field :client_secret, type: String, default: ->{ SecureRandom.hex } |
#creator ⇒ Core::Models::Account
Returns the account that has created this application, considered its owner.
30 |
# File 'lib/core/models/oauth/application.rb', line 30 belongs_to :creator, class_name: 'Core::Models::Account', inverse_of: :applications |
#name ⇒ String
Returns the unique name of the application, mainly used to identify and display it.
14 |
# File 'lib/core/models/oauth/application.rb', line 14 field :name, type: String |
#premium ⇒ Boolean
Returns a value indicating whether the application should automatically receive a token when an account is created, or not.
23 |
# File 'lib/core/models/oauth/application.rb', line 23 field :premium, type: Mongoid::Boolean, default: false |
Instance Method Details
#redirect_uris_values ⇒ Object
Checks the URIs to get sure they are correct, a URI is correct if :
-
it is a string
-
it has a correct URL format.
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/core/models/oauth/application.rb', line 55 def redirect_uris_values redirect_uris.each do |uri| if !uri.is_a? String errors.add(:redirect_uris, 'type') break elsif uri.match(/\Ahttps?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&\/\/=]*)\z/).nil? errors.add(:redirect_uris, 'format') break end end end |