Class: Sitefull::Auth::Base
- Inherits:
-
Object
- Object
- Sitefull::Auth::Base
- Defined in:
- lib/sitefull-cloud/auth/base.rb
Constant Summary collapse
- MISSING_AUTHORIZATION_URI =
'Missing Authorization URL'.freeze
- MISSING_BASE_URI =
'Missing base URL and redirect URL'.freeze
- MISSING_BASE_URI_SCHEME =
'Base URL must be an absolute URL'.freeze
- MISSING_CALLBACK_URI =
'No callback URI specified'.freeze
- MISSING_CLIENT_ID =
'Missing Client ID'.freeze
- MISSING_CLIENT_SECRET =
'Missing Client Secret'.freeze
- MISSING_REDIRECT_URI_SCHEME =
'Redirect URL must be an absolute URL'.freeze
- MISSING_SCOPE =
'Missing scope'.freeze
- MISSING_TOKEN_CREDENTIALS_URI =
'Missing Token Credentials URL'.freeze
Instance Method Summary collapse
- #authorization_uri(_) ⇒ Object
- #authorization_url_options ⇒ Object
- #callback_uri ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #required_settings ⇒ Object
- #scope ⇒ Object
- #token_credentials_uri(_) ⇒ Object
- #token_options ⇒ Object
- #validate(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
15 16 17 |
# File 'lib/sitefull-cloud/auth/base.rb', line 15 def initialize( = {}) @options = validate() if [:validate].to_s.empty? || [:validate] end |
Instance Method Details
#authorization_uri(_) ⇒ Object
38 39 40 |
# File 'lib/sitefull-cloud/auth/base.rb', line 38 def (_) fail MISSING_AUTHORIZATION_URI end |
#authorization_url_options ⇒ Object
30 31 32 |
# File 'lib/sitefull-cloud/auth/base.rb', line 30 def @options.select { |k| [:state, :login_hint, :redirect_uri].include? k.to_sym } end |
#callback_uri ⇒ Object
34 35 36 |
# File 'lib/sitefull-cloud/auth/base.rb', line 34 def callback_uri fail MISSING_CALLBACK_URI end |
#required_settings ⇒ Object
50 51 52 |
# File 'lib/sitefull-cloud/auth/base.rb', line 50 def required_settings [:client_id, :client_secret] end |
#scope ⇒ Object
42 43 44 |
# File 'lib/sitefull-cloud/auth/base.rb', line 42 def scope fail MISSING_SCOPE end |
#token_credentials_uri(_) ⇒ Object
46 47 48 |
# File 'lib/sitefull-cloud/auth/base.rb', line 46 def token_credentials_uri(_) fail MISSING_TOKEN_CREDENTIALS_URI end |
#token_options ⇒ Object
26 27 28 |
# File 'lib/sitefull-cloud/auth/base.rb', line 26 def @options.select { |k| [:authorization_uri, :client_id, :client_secret, :scope, :token_credential_uri, :redirect_uri].include? k.to_sym }.merge(@options[:token] || {}) end |
#validate(options = {}) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/sitefull-cloud/auth/base.rb', line 19 def validate( = {}) fail MISSING_CLIENT_ID if [:client_id].to_s.empty? fail MISSING_CLIENT_SECRET if [:client_secret].to_s.empty? fail MISSING_REDIRECT_URI_SCHEME if ![:redirect_uri].to_s.empty? && URI([:redirect_uri].to_s).scheme.to_s.empty? process() end |