-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add type restrictions to Oauth directory #15687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -72,7 +72,7 @@ class OAuth::Consumer | |||||
# [RFC 5849, Section 2.1](https://tools.ietf.org/html/rfc5849#section-2.1). | ||||||
# | ||||||
# Raises `OAuth::Error` if there was an error getting the request token. | ||||||
def get_request_token(oauth_callback = "oob") # : RequestToken | ||||||
def get_request_token(oauth_callback : String = "oob") : OAuth::RequestToken | ||||||
post(nil, nil, {"oauth_callback" => oauth_callback}, @request_token_uri) do |response| | ||||||
RequestToken.from_response(response.body) | ||||||
end | ||||||
|
@@ -81,7 +81,7 @@ class OAuth::Consumer | |||||
# Returns an authorize URI from a given request token to redirect the user | ||||||
# to obtain an access token, as specified by | ||||||
# [RFC 5849, Section 2.2](https://tools.ietf.org/html/rfc5849#section-2.2). | ||||||
def get_authorize_uri(request_token, oauth_callback = nil) : String | ||||||
def get_authorize_uri(request_token : OAuth::RequestToken, oauth_callback : String? = nil) : String | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto
Suggested change
|
||||||
get_authorize_uri(request_token, oauth_callback) { } | ||||||
end | ||||||
|
||||||
|
@@ -116,7 +116,7 @@ class OAuth::Consumer | |||||
# [RFC 5849, Section 2.3](https://tools.ietf.org/html/rfc5849#section-2.3). | ||||||
# | ||||||
# Raises `OAuth::Error` if there was an error getting the access token. | ||||||
def get_access_token(request_token, oauth_verifier, extra_params = nil) : AccessToken | ||||||
def get_access_token(request_token : OAuth::RequestToken, oauth_verifier : String, extra_params : Hash(String, String)? = nil) : AccessToken | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto
Suggested change
|
||||||
extra_params ||= {} of String => String | ||||||
extra_params["oauth_verifier"] = oauth_verifier | ||||||
post(request_token.token, request_token.secret, extra_params, @access_token_uri) do |response| | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,15 @@ require "base64" | |
require "./access_token" | ||
|
||
class OAuth2::AccessToken::Mac < OAuth2::AccessToken | ||
def self.new(pull : JSON::PullParser) | ||
def self.new(pull : JSON::PullParser) : OAuth2::AccessToken::Mac | ||
OAuth2::AccessToken.new(pull).as(self) | ||
end | ||
|
||
property mac_algorithm : String | ||
property mac_key : String | ||
property issued_at : Int64 | ||
|
||
def initialize(access_token, expires_in, @mac_algorithm, @mac_key, refresh_token = nil, scope = nil, @issued_at = Time.utc.to_unix, extra = nil) | ||
def initialize(access_token : String, expires_in, @mac_algorithm : String, @mac_key : String, refresh_token : String? = nil, scope : String? = nil, @issued_at : Int64 = Time.utc.to_unix, extra : Hash(String, String)? = nil) | ||
super(access_token, expires_in, refresh_token, scope, extra) | ||
end | ||
|
||
|
@@ -34,7 +34,7 @@ class OAuth2::AccessToken::Mac < OAuth2::AccessToken | |
request.headers["Authorization"] = header | ||
end | ||
|
||
def self.signature(ts, nonce, method, uri, host, port, ext, mac_algorithm, mac_key) : String | ||
def self.signature(ts, nonce : String, method : String, uri : String, host : String, port : Int32 | String, ext : String, mac_algorithm : String, mac_key : String) : String | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ha, agreed, good catch. Looks to be caused by this spec that's passing in |
||
normalized_request_string = "#{ts}\n#{nonce}\n#{method}\n#{uri}\n#{host}\n#{port}\n#{ext}\n" | ||
|
||
digest = case mac_algorithm | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Full path is not needed.