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.
def authenticate_resource_request(options) -> Hash
- 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).
-
(Hash) — A hash of the credentials and realm for a valid request,
or
nil
if not valid.
- (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.
def authenticate_temporary_credential_request(options) -> String
oob
will be returned.
- 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).
-
(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.
def authenticate_token_credential_request(options) -> Hash
- 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).
-
(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.
- credential (Proc) — to call.
-
key (String) — provided to the Proc in
credential
-
(Signet::OAuth1::Credential) — credential provided by
credential
(if any).
#client_credential
def client_credential() -> Proc
- (Proc) — lookup the value from this Proc.
#client_credential=
def client_credential=(value) -> Proc
- value (Proc) — lookup the value from this Proc.
- (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.
- key (String) — provided to the #client_credential Proc.
- (Signet::OAuth1::Credential) — The client credential.
#find_temporary_credential
def find_temporary_credential(key) -> Signet::OAuth1::Credential
Find the appropriate client credential by calling the #temporary_credential Proc.
- key (String) — provided to the #temporary_credential Proc.
- (Signet::OAuth1::Credential) — if the credential is found.
#find_token_credential
def find_token_credential(key) -> Signet::OAuth1::Credential
Find the appropriate client credential by calling the #token_credential Proc.
- key (String) — provided to the #token_credential Proc.
- (Signet::OAuth1::Credential) — if the credential is found.
#find_verifier
def find_verifier(verifier) -> Boolean
Determine if the verifier is valid by calling the Proc in #verifier.
- verifier (String) — Key provided to the #verifier Proc.
-
(Boolean) — if the verifier Proc returns anything other than
nil
orfalse
#initialize
def initialize(options) -> Server
Creates an OAuth 1.0 server.
def initialize(options) -> Server
- 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.
- (Server) — a new instance of Server
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
- (Proc) — lookup the value from this Proc.
#nonce_timestamp=
def nonce_timestamp=(value) -> Proc
- value (Proc) — lookup the value from this Proc.
- (Proc) — lookup the value from this Proc.
#request_realm
def request_realm(options) -> String
def request_realm(options) -> String
- 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).
- (String) — The Authorization realm(see RFC 2617) of the request.
#safe_equals?
def safe_equals?(left, right) -> Boolean
Constant time string comparison.
- (Boolean)
#temporary_credential
def temporary_credential() -> Proc
- (Proc) — lookup the value from this Proc.
#temporary_credential=
def temporary_credential=(value) -> Proc
- value (Proc) — lookup the value from this Proc.
- (Proc) — lookup the value from this Proc.
#token_credential
def token_credential() -> Proc
- (Proc) — lookup the value from this Proc.
#token_credential=
def token_credential=(value) -> Proc
- value (Proc) — lookup the value from this Proc.
- (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.
- nonce (String, #to_str) — value from the request
- timestamp (String, #to_str) — value from the request
- (Boolean) — if the nonce/timestamp pair is valid.
#verifier
def verifier() -> Proc
- (Proc) — lookup the value from this Proc.
#verifier=
def verifier=(value) -> Proc
- value (Proc) — lookup the value from this Proc.
- (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.
- headers (Array) — from HTTP request.
- (Hash) — Hash of Authorization header.
#verify_request_components
def verify_request_components(options) -> Hash
Validate and normalize the components from an HTTP request.
def verify_request_components(options) -> Hash
- 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).
- (Hash) — normalized request components