signet - Class Signet::OAuth1::Server (v0.20.0)

Reference documentation and code samples for the signet class Signet::OAuth1::Server.

Inherits

  • Object

Methods

#authenticate_resource_request

  def 
  
 authenticate_resource_request 
 ( 
 options 
 ) 
  
 - 
>  
 Hash 
 

Authenticates a request for a protected resource.

Overloads
  def 
  
 authenticate_resource_request 
 ( 
 options 
 ) 
  
 - 
>  
 Hash 
 
Authenticates a request for a protected resource.
Parameters
  • request(Hash) — The configuration parameters for the request.
  • method(String) — the HTTP method , defaults to GET
  • uri(Addressable::URI, String) — the URI .
  • headers(Hash, Array) — the HTTP headers.
  • body(StringIO, String) — The HTTP body.
  • two_legged(Boolean) — skip the token_credential lookup?
  • adapter(HTTPAdapter) — The HTTP adapter(optional).
Returns
  • (Hash) — A hash of the credentials and realm for a valid request, or nil if not valid.
Raises
  • (TypeError)

#authenticate_temporary_credential_request

  def 
  
 authenticate_temporary_credential_request 
 ( 
 options 
 ) 
  
 - 
>  
 String 
 

Authenticates a temporary credential request. If no oauth_callback is present in the request, oob will be returned.

Overloads
  def 
  
 authenticate_temporary_credential_request 
 ( 
 options 
 ) 
  
 - 
>  
 String 
 
Authenticates a temporary credential request. If no oauth_callback is present in the request, oob will be returned.
Parameters
  • request(Hash) — The configuration parameters for the request.
  • method(String) — the HTTP method , defaults to GET
  • uri(Addressable::URI, String) — the URI .
  • headers(Hash, Array) — the HTTP headers.
  • body(StringIO, String) — The HTTP body.
  • adapter(HTTPAdapter) — The HTTP adapter(optional).
Returns
  • (String) — The oauth_callback value, or false if not valid.

#authenticate_token_credential_request

  def 
  
 authenticate_token_credential_request 
 ( 
 options 
 ) 
  
 - 
>  
 Hash 
 

Authenticates a token credential request.

Overloads
  def 
  
 authenticate_token_credential_request 
 ( 
 options 
 ) 
  
 - 
>  
 Hash 
 
Authenticates a token credential request.
Parameters
  • request(Hash) — The configuration parameters for the request.
  • method(String) — the HTTP method , defaults to GET
  • uri(Addressable::URI, String) — the URI .
  • headers(Hash, Array) — the HTTP headers.
  • body(StringIO, String) — The HTTP body.
  • adapter(HTTPAdapter) — The HTTP adapter(optional).
Returns
  • (Hash) — A hash of credentials and realm for a valid request, or nil if not valid.

#call_credential_lookup

  def 
  
 call_credential_lookup 
 ( 
 credential 
 , 
  
 key 
 ) 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 

Call a credential lookup, and cast the result to a proper Credential.

Parameters
  • credential(Proc) — to call.
  • key(String) — provided to the Proc in credential
Returns

#client_credential

  def 
  
 client_credential 
 () 
  
 - 
>  
 Proc 
 
Returns
  • (Proc) — lookup the value from this Proc.

#client_credential=

  def 
  
 client_credential= 
 ( 
 value 
 ) 
  
 - 
>  
 Proc 
 
Parameter
  • value(Proc) — lookup the value from this Proc.
Returns
  • (Proc) — lookup the value from this Proc.

#find_client_credential

  def 
  
 find_client_credential 
 ( 
 key 
 ) 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 

Find the appropriate client credential by calling the #client_credential Proc.

Parameter
Returns

#find_temporary_credential

  def 
  
 find_temporary_credential 
 ( 
 key 
 ) 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 

Find the appropriate client credential by calling the #temporary_credential Proc.

Parameter
Returns

#find_token_credential

  def 
  
 find_token_credential 
 ( 
 key 
 ) 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 

Find the appropriate client credential by calling the #token_credential Proc.

Parameter
Returns

#find_verifier

  def 
  
 find_verifier 
 ( 
 verifier 
 ) 
  
 - 
>  
 Boolean 
 

Determine if the verifier is valid by calling the Proc in #verifier .

Parameter
  • verifier(String) — Key provided to the #verifier Proc.
Returns
  • (Boolean) — if the verifier Proc returns anything other than nil or false

#initialize

  def 
  
 initialize 
 ( 
 options 
 ) 
  
 - 
>  
 Server 
 

Creates an OAuth 1.0 server.

Overloads
  def 
  
 initialize 
 ( 
 options 
 ) 
  
 - 
>  
 Server 
 
Creates an OAuth 1.0 server.
Parameters
  • nonce_timestamp(Proc) — verify a nonce/timestamp pair.
  • client_credential(Proc) — find a client credential.
  • token_credential(Proc) — find a token credential.
  • temporary_credential(Proc) — find a temporary credential.
  • verifier(Proc) — validate a verifier value.
Returns
  • ( Server ) — a new instance of Server
Example
 server 
  
 = 
  
 Signet 
 :: 
 OAuth1 
 :: 
 Server 
 . 
 new 
 ( 
  
 :nonce_timestamp 
  
 = 
>  
 lambda 
  
 { 
  
 | 
 n 
 , 
 t 
 | 
  
 OauthNonce 
 . 
 remember 
 ( 
 n 
 , 
 t 
 ) 
  
 }, 
  
 :client_credential 
  
 = 
>  
 lambda 
  
 { 
  
 | 
 key 
 | 
  
 ClientCredential 
 . 
 find_by_key 
 ( 
 key 
 ) 
 . 
 to_hash 
  
 }, 
  
 :token_credential 
  
 = 
>  
 lambda 
  
 { 
  
 | 
 key 
 | 
  
 TokenCredential 
 . 
 find_by_key 
 ( 
 key 
 ) 
 . 
 to_hash 
  
 }, 
  
 :temporary_credential 
  
 = 
>  
 lambda 
  
 { 
  
 | 
 key 
 | 
  
 TemporaryCredential 
 . 
 find_by_key 
 ( 
 key 
 ) 
 . 
 to_hash 
  
 }, 
  
 :verifier 
  
 = 
>  
 lambda 
  
 { 
 | 
 verifier 
 | 
  
 Verifier 
 . 
 find_by_verifier 
 ( 
 verifier 
 ) 
 . 
 active? 
  
 } 
 ) 

#nonce_timestamp

  def 
  
 nonce_timestamp 
 () 
  
 - 
>  
 Proc 
 
Returns
  • (Proc) — lookup the value from this Proc.

#nonce_timestamp=

  def 
  
 nonce_timestamp= 
 ( 
 value 
 ) 
  
 - 
>  
 Proc 
 
Parameter
  • value(Proc) — lookup the value from this Proc.
Returns
  • (Proc) — lookup the value from this Proc.

#request_realm

  def 
  
 request_realm 
 ( 
 options 
 ) 
  
 - 
>  
 String 
 
Overloads
  def 
  
 request_realm 
 ( 
 options 
 ) 
  
 - 
>  
 String 
 
Parameters
  • request(Hash) — A pre-constructed request to verify.
  • method(String) — the HTTP method , defaults to GET
  • uri(Addressable::URI, String) — the URI .
  • headers(Hash, Array) — the HTTP headers.
  • body(StringIO, String) — The HTTP body.
  • adapter(HTTPAdapter) — The HTTP adapter(optional).
Returns
  • (String) — The Authorization realm(see RFC 2617) of the request.

#safe_equals?

  def 
  
 safe_equals? 
 ( 
 left 
 , 
  
 right 
 ) 
  
 - 
>  
 Boolean 
 

Constant time string comparison.

Returns
  • (Boolean)

#temporary_credential

  def 
  
 temporary_credential 
 () 
  
 - 
>  
 Proc 
 
Returns
  • (Proc) — lookup the value from this Proc.

#temporary_credential=

  def 
  
 temporary_credential= 
 ( 
 value 
 ) 
  
 - 
>  
 Proc 
 
Parameter
  • value(Proc) — lookup the value from this Proc.
Returns
  • (Proc) — lookup the value from this Proc.

#token_credential

  def 
  
 token_credential 
 () 
  
 - 
>  
 Proc 
 
Returns
  • (Proc) — lookup the value from this Proc.

#token_credential=

  def 
  
 token_credential= 
 ( 
 value 
 ) 
  
 - 
>  
 Proc 
 
Parameter
  • value(Proc) — lookup the value from this Proc.
Returns
  • (Proc) — lookup the value from this Proc.

#validate_nonce_timestamp

  def 
  
 validate_nonce_timestamp 
 ( 
 nonce 
 , 
  
 timestamp 
 ) 
  
 - 
>  
 Boolean 
 

Determine if the supplied nonce/timestamp pair is valid by calling the #nonce_timestamp Proc.

Parameters
  • nonce(String, #to_str) — value from the request
  • timestamp(String, #to_str) — value from the request
Returns
  • (Boolean) — if the nonce/timestamp pair is valid.

#verifier

  def 
  
 verifier 
 () 
  
 - 
>  
 Proc 
 
Returns
  • (Proc) — lookup the value from this Proc.

#verifier=

  def 
  
 verifier= 
 ( 
 value 
 ) 
  
 - 
>  
 Proc 
 
Parameter
  • value(Proc) — lookup the value from this Proc.
Returns
  • (Proc) — lookup the value from this Proc.

#verify_auth_header_components

  def 
  
 verify_auth_header_components 
 ( 
 headers 
 ) 
  
 - 
>  
 Hash 
 

Validate and normalize the HTTP Authorization header.

Parameter
  • headers(Array) — from HTTP request.
Returns
  • (Hash) — Hash of Authorization header.

#verify_request_components

  def 
  
 verify_request_components 
 ( 
 options 
 ) 
  
 - 
>  
 Hash 
 

Validate and normalize the components from an HTTP request.

Overloads
  def 
  
 verify_request_components 
 ( 
 options 
 ) 
  
 - 
>  
 Hash 
 
Validate and normalize the components from an HTTP request.
Parameters
  • request(Faraday::Request) — A pre-constructed request to verify.
  • method(String) — the HTTP method , defaults to GET
  • uri(Addressable::URI, String) — the URI .
  • headers(Hash, Array) — the HTTP headers.
  • body(StringIO, String) — The HTTP body.
  • adapter(HTTPAdapter) — The HTTP adapter(optional).
Returns
  • (Hash) — normalized request components
Create a Mobile Website
View Site in Mobile | Classic
Share by: