access_token_agent 3.4.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0fd60d58c6d3a25047e8dc8658c0e020aead8ae7
4
- data.tar.gz: 91938386479d3131acf3f0276e2999847aed42a4
2
+ SHA256:
3
+ metadata.gz: 18af8e541c53b820506f84156a99fb17be090ab614f76c435f4129e89ac7c4d8
4
+ data.tar.gz: 2768ea522b78cb1735fba2caedead636c7ff0e2f504bb67a5101f7c1390bb072
5
5
  SHA512:
6
- metadata.gz: b4847fe284c32ae55edcfbee16843b9aac31862418f9ebdc98a565c75a83628a7690651272489eaa9bca2b38759e8ea005d05230c4b380491b101e8fd001bce0
7
- data.tar.gz: ca7f0a9d57f69a6b097f4a531743f54c957533671701c7f33cea1cf744e83ddf026d0bc85709be7e3c10f430bf760f23d64c4659cdf783b801f09047a8990d09
6
+ metadata.gz: 15ad3cf054ccbc0057469518aeb173a19a6f001689767476eb4c992d3f380bb9b80cb60add5909932dfecac9508f500f593b11879cc6d0eb54b529a611b0590e
7
+ data.tar.gz: 458f7aec7acbacdc824c5200b38833e89a3c5cdb4b83b5fe4514ec9a6f446cd9370df17b503578af39449eae04fec2186b298c47b5d2ad7214d884594c970e3e
data/.gitignore CHANGED
@@ -2,5 +2,6 @@ Gemfile.lock
2
2
  coverage/
3
3
  tmp/
4
4
 
5
+ .ruby-version
5
6
  .ruby-gemset
6
7
  access_token_agent-*.gem
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,47 @@
1
+ image: public.ecr.aws/docker/library/ruby
2
+
3
+ stages:
4
+ - test
5
+ - publish
6
+
7
+ before_script:
8
+ - "echo ':ssl_verify_mode: 0' >> ~/.gemrc"
9
+ - bundle config ssl_verify_mode 0
10
+ - bundle install --path=/tmp/bundler --jobs=8 --quiet
11
+
12
+ rubocop:
13
+ stage: test
14
+ image: public.ecr.aws/docker/library/ruby:2.7
15
+ script:
16
+ - bundle exec rubocop
17
+
18
+ rspec_latest:
19
+ stage: test
20
+ script:
21
+ - bundle exec rspec
22
+
23
+ rspec_2.6:
24
+ stage: test
25
+ image: public.ecr.aws/docker/library/ruby:2.6
26
+ script:
27
+ - bundle exec rspec
28
+
29
+ rspec_2.5:
30
+ stage: test
31
+ image: public.ecr.aws/docker/library/ruby:2.5
32
+ script:
33
+ - bundle exec rspec
34
+
35
+ rspec_2.2:
36
+ stage: test
37
+ image: ruby:2.2
38
+ script:
39
+ - bundle exec rspec
40
+
41
+ publish_gem:
42
+ stage: publish
43
+ script:
44
+ - gem build access_token_agent.gemspec
45
+ - gem push $(find `pwd` -name "access_token_agent-*.gem")
46
+ only:
47
+ - main
data/.rubocop.yml CHANGED
@@ -20,6 +20,16 @@ Metrics/BlockLength:
20
20
  - 'config/environments/*.rb' # instead of excluding all :configure methods
21
21
  - 'config/routes.rb'
22
22
 
23
+ # The maximum amount of positional arguments in a method really shouldn't exceed
24
+ # the rubocop default of 5.
25
+ # However, keyword arguments do not make a method signature as unreadable as positional
26
+ # arguments. There are valid cases for longer argument lists (e.g. data objects or
27
+ # DSLs with implicit default values).
28
+ # In those cases keyword args provide a good balance between readability and the need to
29
+ # pass more arguments into an object.
30
+ Metrics/ParameterLists:
31
+ CountKeywordArgs: false
32
+
23
33
  Style/Documentation:
24
34
  Enabled: false
25
35
 
data/CHANGELOG.md CHANGED
@@ -1,6 +1,19 @@
1
- ## master
1
+ ## 4.0.0 (2024-07-25)
2
2
 
3
- *no unreleased changes*
3
+ - BREAKING: Remove deprecated `authenticate` method, use `token` instead
4
+
5
+ ## 3.5.2 (2024-06-12) yanked
6
+
7
+ - Use the new default branch (`main`, replacing `master`) in the publish job.
8
+
9
+ ## 3.5.1 (2023-05-24) yanked
10
+
11
+ - Publish gem to the new gem server
12
+
13
+ ## 3.5.0
14
+
15
+ - Support requesting scopes
16
+ - Add requirement for Ruby 2.2 to gemspec (this was an implicit requirement before)
4
17
 
5
18
  ## 3.4.0
6
19
 
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  source 'https://rubygems.org'
3
4
 
data/README.md CHANGED
@@ -1,7 +1,4 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/access_token_agent.svg)](https://badge.fury.io/rb/access_token_agent)
2
- [![Build Status](https://travis-ci.org/kaeuferportal/access_token_agent.svg?branch=master)](https://travis-ci.org/kaeuferportal/access_token_agent)
3
- [![Code Climate](https://codeclimate.com/github/kaeuferportal/access_token_agent/badges/gpa.svg)](https://codeclimate.com/github/kaeuferportal/access_token_agent)
4
- [![Test Coverage](https://codeclimate.com/github/kaeuferportal/access_token_agent/badges/coverage.svg)](https://codeclimate.com/github/kaeuferportal/access_token_agent/coverage)
5
2
 
6
3
  # AccessTokenAgent
7
4
 
@@ -40,6 +37,8 @@ Optional parameters:
40
37
  * `access_token_path` - Allows to customize the HTTP path where the
41
38
  access token needs to be requested.
42
39
  **Default:** `/oauth/token`
40
+ * `scopes` - An array of scopes to be requested from the authorization server
41
+ **Default:** no scopes
43
42
 
44
43
  ### Example
45
44
 
@@ -64,21 +63,21 @@ AccessTokenAgent::Connector.instance = AccessTokenAgent::Connector.new(...)
64
63
  ## Usage
65
64
 
66
65
  Set up an AcccessTokenAgent::Connector instance (see Configuration) and call
67
- `authenticate` on it to receive your access_token.
66
+ `token` on it to receive your access_token.
68
67
 
69
68
  ```ruby
70
- AccessTokenAgent::Connector.instance.authenticate
69
+ AccessTokenAgent::Connector.instance.token
71
70
  => "XYZ"
72
71
  ```
73
72
 
74
- When no valid AccessToken is present a call to authenticate returns one of the
73
+ When no valid AccessToken is present a call to token returns one of the
75
74
  following:
76
75
  - a Bearer Token if the credentials are valid (auth response code 200)
77
76
  - raises an UnauthorizedError if the credentials are invalid (auth response
78
77
  code 401)
79
78
  - raises an Error if the auth response code is neither 200 nor 401
80
79
 
81
- As long as a valid AccessToken is present a call to authenticate simply returns
80
+ As long as a valid AccessToken is present a call to token simply returns
82
81
  that AccessToken. An AccessToken is valid for a limited time. The exact value is
83
82
  determined by the auth response which contains an `expires_at` parameter.
84
83
 
@@ -5,23 +5,24 @@ require 'access_token_agent/version'
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'access_token_agent'
7
7
  s.version = AccessTokenAgent::VERSION
8
- s.date = '2016-04-08'
8
+ s.date = '2020-10-02'
9
9
  s.summary = 'Handles authentication against an OAuth2 provider'
10
- s.homepage = 'https://github.com/kaeuferportal/access_token_agent'
11
- s.description = 'Retrieves an access token from an OAuth2 provider' \
10
+ s.homepage = 'https://github.com/aroundhome/access_token_agent'
11
+ s.description = 'Retrieves an access token from an OAuth2 provider ' \
12
12
  'using the supplied credentials.'
13
- s.authors = ['Beko Käuferportal GmbH']
14
- s.email = 'oss@kaeuferportal.de'
13
+ s.authors = ['be Around GmbH']
14
+ s.email = 'oss@aroundhome.de'
15
15
  s.license = 'MIT'
16
16
  s.files = `git ls-files -z`.split("\x0")
17
17
  .reject { |f| f.match(%r{^spec/}) }
18
18
 
19
- s.add_development_dependency 'bundler', '~> 1.11'
20
- s.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
19
+ s.required_ruby_version = '>= 2.2'
20
+
21
+ s.add_development_dependency 'bundler', '> 1.11', '< 3'
21
22
  s.add_development_dependency 'pry', '~> 0.10'
22
23
  s.add_development_dependency 'rspec', '~> 3.4'
23
24
  s.add_development_dependency 'rubocop', '0.51'
24
25
  s.add_development_dependency 'simplecov', '~> 0.16'
25
- s.add_development_dependency 'vcr', '~> 3.0'
26
- s.add_development_dependency 'webmock', '~> 1.24'
26
+ s.add_development_dependency 'vcr', '~> 5.0'
27
+ s.add_development_dependency 'webmock', '~> 3.0'
27
28
  end
@@ -12,12 +12,14 @@ module AccessTokenAgent
12
12
  client_id:,
13
13
  client_secret:,
14
14
  fake_auth: false,
15
- access_token_path: '/oauth/token')
15
+ access_token_path: '/oauth/token',
16
+ scopes: nil)
16
17
  @host = host
17
18
  @client_id = client_id
18
19
  @client_secret = client_secret
19
20
  @fake_auth = fake_auth
20
21
  @access_token_path = access_token_path
22
+ @scopes = scopes
21
23
  end
22
24
 
23
25
  def http_auth_header
@@ -31,12 +33,6 @@ module AccessTokenAgent
31
33
  @known_token.value
32
34
  end
33
35
 
34
- def authenticate
35
- warn "[DEPRECATION] `#{self.class}.authenticate` is deprecated. " \
36
- 'Use `token` instead.'
37
- token
38
- end
39
-
40
36
  private
41
37
 
42
38
  def fetch_token
@@ -58,7 +54,7 @@ module AccessTokenAgent
58
54
  def perform_request
59
55
  request = Net::HTTP::Post.new(auth_uri)
60
56
  request.basic_auth @client_id, @client_secret
61
- request.form_data = { 'grant_type' => 'client_credentials' }
57
+ request.form_data = form_data
62
58
  use_tls = auth_uri.scheme == 'https'
63
59
  Net::HTTP.start(auth_uri.hostname,
64
60
  auth_uri.port,
@@ -70,5 +66,11 @@ module AccessTokenAgent
70
66
  def auth_uri
71
67
  @auth_uri ||= URI("#{@host}#{@access_token_path}")
72
68
  end
69
+
70
+ def form_data
71
+ result = { 'grant_type' => 'client_credentials' }
72
+ result['scope'] = @scopes.join(' ') if @scopes
73
+ result
74
+ end
73
75
  end
74
76
  end
@@ -1,3 +1,3 @@
1
1
  module AccessTokenAgent
2
- VERSION = '3.4.0'.freeze
2
+ VERSION = '4.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,43 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: access_token_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Beko Käuferportal GmbH
8
- autorequire:
7
+ - be Around GmbH
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-08 00:00:00.000000000 Z
11
+ date: 2020-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.11'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3'
20
23
  type: :development
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">"
25
28
  - !ruby/object:Gem::Version
26
29
  version: '1.11'
27
- - !ruby/object:Gem::Dependency
28
- name: codeclimate-test-reporter
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
30
+ - - "<"
39
31
  - !ruby/object:Gem::Version
40
- version: '1.0'
32
+ version: '3'
41
33
  - !ruby/object:Gem::Dependency
42
34
  name: pry
43
35
  requirement: !ruby/object:Gem::Requirement
@@ -100,39 +92,39 @@ dependencies:
100
92
  requirements:
101
93
  - - "~>"
102
94
  - !ruby/object:Gem::Version
103
- version: '3.0'
95
+ version: '5.0'
104
96
  type: :development
105
97
  prerelease: false
106
98
  version_requirements: !ruby/object:Gem::Requirement
107
99
  requirements:
108
100
  - - "~>"
109
101
  - !ruby/object:Gem::Version
110
- version: '3.0'
102
+ version: '5.0'
111
103
  - !ruby/object:Gem::Dependency
112
104
  name: webmock
113
105
  requirement: !ruby/object:Gem::Requirement
114
106
  requirements:
115
107
  - - "~>"
116
108
  - !ruby/object:Gem::Version
117
- version: '1.24'
109
+ version: '3.0'
118
110
  type: :development
119
111
  prerelease: false
120
112
  version_requirements: !ruby/object:Gem::Requirement
121
113
  requirements:
122
114
  - - "~>"
123
115
  - !ruby/object:Gem::Version
124
- version: '1.24'
125
- description: Retrieves an access token from an OAuth2 providerusing the supplied credentials.
126
- email: oss@kaeuferportal.de
116
+ version: '3.0'
117
+ description: Retrieves an access token from an OAuth2 provider using the supplied
118
+ credentials.
119
+ email: oss@aroundhome.de
127
120
  executables: []
128
121
  extensions: []
129
122
  extra_rdoc_files: []
130
123
  files:
131
124
  - ".gitignore"
125
+ - ".gitlab-ci.yml"
132
126
  - ".rspec"
133
127
  - ".rubocop.yml"
134
- - ".ruby-version"
135
- - ".travis.yml"
136
128
  - CHANGELOG.md
137
129
  - Gemfile
138
130
  - LICENSE.md
@@ -149,11 +141,11 @@ files:
149
141
  - lib/access_token_agent/unauthorized_error.rb
150
142
  - lib/access_token_agent/unsupported_token_type_error.rb
151
143
  - lib/access_token_agent/version.rb
152
- homepage: https://github.com/kaeuferportal/access_token_agent
144
+ homepage: https://github.com/aroundhome/access_token_agent
153
145
  licenses:
154
146
  - MIT
155
147
  metadata: {}
156
- post_install_message:
148
+ post_install_message:
157
149
  rdoc_options: []
158
150
  require_paths:
159
151
  - lib
@@ -161,16 +153,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
153
  requirements:
162
154
  - - ">="
163
155
  - !ruby/object:Gem::Version
164
- version: '0'
156
+ version: '2.2'
165
157
  required_rubygems_version: !ruby/object:Gem::Requirement
166
158
  requirements:
167
159
  - - ">="
168
160
  - !ruby/object:Gem::Version
169
161
  version: '0'
170
162
  requirements: []
171
- rubyforge_project:
172
- rubygems_version: 2.2.5
173
- signing_key:
163
+ rubygems_version: 3.5.11
164
+ signing_key:
174
165
  specification_version: 4
175
166
  summary: Handles authentication against an OAuth2 provider
176
167
  test_files: []
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.1.10
data/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- language: ruby
2
- script:
3
- - bundle exec rspec && codeclimate-test-reporter
4
- - bundle exec rubocop
5
-
6
- addons:
7
- code_climate:
8
- repo_token:
9
- secure: "tsEpSMfYQHfnm5l9zkdksmTcdV/hjq28HsKh7+tXefWbNbMksrzWlonuZsoQSeLx8OdG5dcGREY3JVbWUl8CxILZ/j8rse0CBpW1S/sy7sz7KQEaBgTq+BxJiFyjPibul91X7TcMHVLpo2c2bIM353HJW4Sf0gT5rhbykek2YHXsvHXlDv4dkE/PL0yZylgDi8zC6dXl9IrjsqgPcTwtCAOM2o1+NhNBiyBWJqQyfhv2N72dml3mk8rQ9WszyRhHmIUhHehdgYcbOrydlEclOHwuszIQd0z2wpJ9HMlvQFtmH/muW4XTf/VNu3XaZr1OYwzBZBeC9Ngfoqn/7Bs0p815NrRcKc9oq+hIyjyd6Mj7Asqcs1+JxakzcVdW6Enf3ZL7F7fsmmB4mQkATEcpBv8G4aN3lFkBmIZdx16oyMQWrLPPzsFXgSdARdUczdtgfnAFT3IB311CnT6zxPCL8FBI/KiHK9FXc6FBGv030doIhr3pDUjMkx35VYN5cvixf+oHMYg4/XuoO+HGwdViA/P8gAUGs5bQL5kY6jcYSTsa8KlzKfgUcK1buWblHfTSEKdMOnKRSBvfS9S3VcPt5ZpZ62Cfbqfjn4lPa5UxcOyb3abk3s2ikKbftGUQk8k4qlhednki3yV71xKhpQsiO/ufNCnp6jXAV2p/KoM2QjA="