Module: Misty::Auth::Token
- Includes:
- HTTP::NetHTTP
- Defined in:
- lib/misty.rb,
lib/misty/errors.rb,
lib/misty/auth/token.rb,
lib/misty/auth/token/v2.rb,
lib/misty/auth/token/v3.rb
Defined Under Namespace
Classes: ExpiryError, URLError, V2, V3
Instance Attribute Summary collapse
-
#catalog ⇒ Object
readonly
Returns the value of attribute catalog.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#expires ⇒ Object
readonly
Returns the value of attribute expires.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
Methods included from HTTP::NetHTTP
Instance Attribute Details
#catalog ⇒ Object (readonly)
Returns the value of attribute catalog.
6 7 8 |
# File 'lib/misty/auth/token.rb', line 6 def catalog @catalog end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/misty/auth/token.rb', line 6 def data @data end |
#expires ⇒ Object (readonly)
Returns the value of attribute expires.
6 7 8 |
# File 'lib/misty/auth/token.rb', line 6 def expires @expires end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/misty/auth/token.rb', line 6 def token @token end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
6 7 8 |
# File 'lib/misty/auth/token.rb', line 6 def user @user end |
Class Method Details
Instance Method Details
#get ⇒ Object
35 36 37 38 |
# File 'lib/misty/auth/token.rb', line 35 def get set(authenticate(@creds)) if expired? @token end |
#initialize(auth) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/misty/auth/token.rb', line 16 def initialize(auth) @log = auth[:log] if auth[:context] && auth[:context][:token] && auth[:context][:expires] && auth[:context][:catalog] # Bypass authentication @catalog = Misty::Auth::Catalog.new(auth[:context][:catalog]) @expires = auth[:context][:expires] @token = auth[:context][:token] else raise URLError, 'No URL provided' if auth[:url].nil? || auth[:url].empty? @creds = { :data => set_credentials(auth), :ssl_verify_mode => auth[:ssl_verify_mode].nil? ? Misty::Config::SSL_VERIFY_MODE : auth[:ssl_verify_mode], :uri => URI.parse(auth[:url]) } set(authenticate(@creds)) end end |