Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Removed

## [1.1.0] 2022-08-26
## [1.1.0] 2022-08-29
### Changed
* `OAuth::CLI` has been extracted to a new gem, `oauth-tty`, hosted on [Gitlab](https://gitlab.com/oauth-xx/oauth-tty)
* The public API of `oauth-tty` is backwards compatible (meaning `OAuth::CLI`)
* The change within the `oauth` gem is backwards compatible as `oauth-tty` has been added as a dependency
* Minor version bump is cautionary, as many lines of code have changed.
* `OAuth::Comsumer#options` hash is now handled by `snaky_hash`, which was extracted from `oauth2`
* symbolized keys, dot-access and snake-case are now normalized

## [1.0.0] 2022-08-23
### Changed
Expand Down
1 change: 1 addition & 0 deletions lib/oauth.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

# third party gems
require "snaky_hash"
require "version_gem"

require "oauth/version"
Expand Down
87 changes: 45 additions & 42 deletions lib/oauth/consumer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,47 +30,49 @@ class Consumer
end
CA_FILE = nil unless defined?(CA_FILE)

@@default_options = {
# Signature method used by server. Defaults to HMAC-SHA1
signature_method: "HMAC-SHA1",

# default paths on site. These are the same as the defaults set up by the generators
request_token_path: "/oauth/request_token",
authenticate_path: "/oauth/authenticate",
authorize_path: "/oauth/authorize",
access_token_path: "/oauth/access_token",

proxy: nil,
# How do we send the oauth values to the server see
# https://oauth.net/core/1.0/#consumer_req_param for more info
#
# Possible values:
#
# :header - via the Authorize header (Default) ( option 1. in spec)
# :body - url form encoded in body of POST request ( option 2. in spec)
# :query_string - via the query part of the url ( option 3. in spec)
scheme: :header,

# Default http method used for OAuth Token Requests (defaults to :post)
http_method: :post,

# Add a custom ca_file for consumer
# :ca_file => '/etc/certs.pem'

# Possible values:
#
# nil, false - no debug output
# true - uses $stdout
# some_value - uses some_value
debug_output: nil,

# Defaults to producing a body_hash as part of the signature but
# can be disabled since it's not officially part of the OAuth 1.0
# spec. Possible values are true and false
body_hash_enabled: true,

oauth_version: "1.0"
}
@@default_options = SnakyHash::SymbolKeyed.new(
{
# Signature method used by server. Defaults to HMAC-SHA1
signature_method: "HMAC-SHA1",

# default paths on site. These are the same as the defaults set up by the generators
request_token_path: "/oauth/request_token",
authenticate_path: "/oauth/authenticate",
authorize_path: "/oauth/authorize",
access_token_path: "/oauth/access_token",

proxy: nil,
# How do we send the oauth values to the server see
# https://oauth.net/core/1.0/#consumer_req_param for more info
#
# Possible values:
#
# :header - via the Authorize header (Default) ( option 1. in spec)
# :body - url form encoded in body of POST request ( option 2. in spec)
# :query_string - via the query part of the url ( option 3. in spec)
scheme: :header,

# Default http method used for OAuth Token Requests (defaults to :post)
http_method: :post,

# Add a custom ca_file for consumer
# :ca_file => '/etc/certs.pem'

# Possible values:
#
# nil, false - no debug output
# true - uses $stdout
# some_value - uses some_value
debug_output: nil,

# Defaults to producing a body_hash as part of the signature but
# can be disabled since it's not officially part of the OAuth 1.0
# spec. Possible values are true and false
body_hash_enabled: true,

oauth_version: "1.0"
}
)

attr_accessor :options, :key, :secret
attr_writer :site, :http
Expand Down Expand Up @@ -103,7 +105,8 @@ def initialize(consumer_key, consumer_secret, options = {})
@secret = consumer_secret

# ensure that keys are symbols
@options = @@default_options.merge(options.transform_keys(&:to_sym))
snaky_options = SnakyHash::SymbolKeyed.new(options)
@options = @@default_options.merge(snaky_options)
end

# The default http method
Expand Down
7 changes: 4 additions & 3 deletions oauth.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Gem::Specification.new do |spec|
# It is now a dependency for backward compatibility.
# The dependency will be removed with release 2.0, by April 2023.
spec.add_dependency("oauth-tty", ["~> 1.0", ">= 1.0.1"])
spec.add_dependency("snaky_hash", "~> 2.0")
spec.add_dependency("version_gem", "~> 1.1")

spec.name = "oauth"
Expand Down Expand Up @@ -36,13 +37,13 @@ Gem::Specification.new do |spec|
spec.post_install_message = "
You have installed oauth version #{OAuth::Version::VERSION}, congratulations!

Non-commercial support for the 1.0.x series will end in April, 2025. Please make a plan to upgrade to the next version prior to that date.
The only breaking change will be dropped support for Ruby 2.7.
Non-commercial support for the 1.x series will end by April, 2025. Please make a plan to upgrade to the next version prior to that date.
The only breaking change will be dropped support for Ruby 2.7 and any other versions which will also have reached EOL by then.

Please see:
• https://github.com/oauth-xx/oauth/blob/main/SECURITY.md

Note also that I, and this project, am in the process of leaving Github.
Note also that I am, and this project is, in the process of leaving Github.
I wrote about some of the reasons here:
• https://dev.to/galtzo/im-leaving-github-50ba

Expand Down